Proprietary word translation model training method, device, equipment and storage medium
By using random noise processing and iterative training methods in neural network machine translation models, the translation inaccuracy problem caused by proprietary word matching errors is solved, and the robustness and accuracy of the translation model are improved.
Patent Information
- Application Number
- CN202211686008.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-27
- Publication Date
- 2024-11-12
- Estimated Expiration
- 2042-12-27
AI Technical Summary
Existing neural network machine translation models are prone to error matching when matching proprietary words, resulting in inaccurate translation results. Especially in languages with phonetic rather than meaning, the probability of matching errors is high, resulting in semantic errors.
By obtaining the source language data, random numbers are generated based on the preset probability distribution, and random noise is decided based on the random numbers and thresholds, the training data set is generated and iteratively trained to improve the robustness of the model.
It reduces the probability of translation errors caused by mismatch in actual use of the proprietary word translation model, and improves the accuracy and robustness of the translation.
Smart Images

Figure CN116167388B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of machine translation, and in particular relates to a method, device, equipment and storage medium for training a proprietary word translation model. Background Art
[0002] MT (Machine Translation), also known as automatic translation, is the process of using computers to convert a natural source language into another natural target language. It generally refers to the translation of sentences and full texts between natural languages. NMT (Neural Machine Translation) is the latest generation of machine translation technology based on neural networks.
[0003] The existing neural network machine translation model has a proprietary word translation function. The proprietary word translation function means that when the model is used for translation, based on the correspondence between certain input-end words or phrases and target-end words or phrases, the words or phrases in the input sentence are translated into the specified target-end words or phrases while the input language sentence is translated into the target language sentence, thereby improving the accuracy of the translation. Since there are multiple groups of correspondences between the input-end words or phrases and the target-end words or phrases when used, the multiple groups of correspondences are referred to as dictionaries below. Before the model is used for translation, the words or phrases in the dictionary will be matched in the input sentence. If the match is successful, the words or phrases in the input sentence will be translated into the specified target-end words or phrases while the input language sentence is translated into the target language sentence.
[0004] However, when using this model for translation, it is necessary to match the input sentence with proper words according to the dictionary, which may cause input matching errors. For example, the original input sentence is "Xiao Liu is very happy". During the actual translation, Liu Ting, as a name, was added with the proper word translation, causing the input to incorrectly match "Liu Ting". That is, the matching error is caused by the characteristics of the language itself, which leads to the translation error of the entire sentence. Moreover, this matching error is more likely to occur in languages where words are not separated and the text is phonetic rather than semantic. The above-mentioned matching error problem often occurs, resulting in semantic errors in the translation results and inaccurate translation results. Summary of the invention
[0005] The present invention provides a method, device, equipment and storage medium for training a proper word translation model to solve the problem that the translation result output by the translation model is inaccurate due to proper word matching errors.
[0006] In order to solve the above-mentioned technical problems, the present invention is achieved as follows:
[0007] In a first aspect, the present invention provides a method for training a proper word translation model, the method comprising:
[0008] Acquire first source language data, and generate a random number corresponding to the first source language data according to a preset probability distribution;
[0009] According to the random number and a preset threshold, adding pre-generated random noise to the first source language data to obtain a training data set;
[0010] The preset machine translation model is trained according to the training data set and the target language data corresponding to the training data set to obtain the special word translation model.
[0011] Optionally, the adding pre-generated random noise to the first source language data according to the random number and a preset threshold value to obtain a training data set includes:
[0012] If the random number is less than or equal to a preset threshold, determining to add pre-generated random noise to the first source language data, and storing the processed first source language data in the training data set;
[0013] If the random number is greater than the preset threshold, the first source language data is stored in the training data set.
[0014] Optionally, the adding pre-generated random noise to the first source language data according to the random number and a preset threshold value to obtain a training data set includes:
[0015] Generating a random length number of word tokens according to the first source language data and the preset probability distribution;
[0016] According to the random length number, obtaining a word token of the random length number;
[0017] When a preset random condition is met, random noise is generated based on the acquired word tokens; wherein the random noise includes randomly selecting a preset number of first word tokens from the word tokens corresponding to the target language data on the target end and randomly rearranging and randomly selecting a preset number of second word tokens from the word tokens corresponding to the target language data on the target end.
[0018] Optionally, the adding pre-generated random noise to the first source language data according to the random number and a preset threshold value to obtain a training data set includes:
[0019] If the preset random condition is met, pre-generated random noise is added to the first source language data to obtain the training data set, the training data set comprising: a preset number of first word tokens randomly selected from the corresponding word tokens of the target language data on the target end are spliced after the first source language data, and a preset number of second word tokens randomly selected from the corresponding word tokens of the target language data on the target end are spliced after the first source language data by random rearrangement;
[0020] If the preset random condition is not met, the word tokens of the obtained random length are concatenated to the first source language data and stored in the training data set.
[0021] Optionally, the step of training a preset machine translation model according to the training data set and the target language data corresponding to the training data set to obtain the special word translation model includes:
[0022] Acquire first translation data output by the preset machine translation model according to the training data set;
[0023] generating a loss function value according to the first translation data and the target language data;
[0024] Iteratively adjusting the model parameters of the preset machine translation model and the training data set according to the loss function value;
[0025] If the adjustment is made to satisfy the convergence condition of the proprietary word translation, the trained proprietary word translation model is obtained.
[0026] Optionally, after training a preset machine translation model according to the training data set and the target language data corresponding to the training data set to obtain the special word translation model, the method further includes:
[0027] Based on the trained special word translation model, according to the correspondence between the input-end vocabulary or phrase and the target-end vocabulary or phrase, adding the target-end special word to the first source language data at the input end;
[0028] Output the target language data corresponding to the first source language data including the target-side specific words.
[0029] In a second aspect, the present invention provides a device for training a proper word translation model, the device comprising:
[0030] A data acquisition module, configured to acquire first source language data and generate a random number corresponding to the first source language data according to a preset probability distribution;
[0031] A data processing module, configured to add pre-generated random noise to the first source language data according to the random number and a preset threshold value to obtain a training data set;
[0032] The model training module is used to train a preset machine translation model according to the training data set and the target language data corresponding to the training data set to obtain the special word translation model.
[0033] Optionally, the data processing module includes:
[0034] A first data processing submodule, configured to determine to add pre-generated random noise to the first source language data if the random number is less than or equal to a preset threshold, and store the processed first source language data in the training data set;
[0035] The second data processing submodule is configured to store the first source language data into the training data set if the random number is greater than the preset threshold.
[0036] Optionally, the device further comprises:
[0037] A first generating module, configured to generate a random length number of a word token according to the first source language data and the preset probability distribution;
[0038] A second acquisition module is used to acquire a word token of a random length according to the random length;
[0039] The second generating module is used to generate random noise according to the acquired word tokens when a preset random condition is met; wherein the random noise includes randomly selecting a preset number of first word tokens from the word tokens corresponding to the target language data on the target end and randomly rearranging and randomly selecting a preset number of second word tokens from the word tokens corresponding to the target language data on the target end.
[0040] Optionally, the data processing module includes:
[0041] A first data processing subunit is configured to add pre-generated random noise to the first source language data if a preset random condition is met, so as to obtain the training data set, wherein the training data set includes: a preset number of first word tokens randomly selected from the corresponding word tokens of the target language data at the target end are spliced after the first source language data, and a preset number of second word tokens randomly selected from the corresponding word tokens of the target language data at the target end are spliced after the first source language data;
[0042] The second data processing subunit is used for concatenating the word tokens of the obtained random length to the first source language data and storing them in the training data set if the preset random condition is not met.
[0043] Optionally, the model training module includes:
[0044] An acquisition submodule, configured to acquire first translation data output by the preset machine translation model according to the training data set;
[0045] A third generating submodule, configured to generate a loss function value according to the first translation data and the target language data;
[0046] An adjustment submodule, used for iteratively adjusting the model parameters of the preset machine translation model and the training data set according to the loss function value;
[0047] The training submodule is used to obtain the trained proprietary word translation model if the proper word translation convergence condition is satisfied.
[0048] Optionally, the device further includes:
[0049] A translation module, configured to add the target-side proprietary words to the first source language data at the input end based on the trained proprietary word translation model and according to the correspondence between the input-side proprietary words and the target-side proprietary words;
[0050] The output module is used to output the target language data corresponding to the first source language data including the target-side specific words.
[0051] In a third aspect, the present invention provides an electronic device, comprising: a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the processor implements the above-mentioned proper word translation model training method when executing the program.
[0052] In a fourth aspect, the present invention provides a readable storage medium, which, when the instructions in the storage medium are executed by a processor of an electronic device, enables the electronic device to execute the above-mentioned proper word translation model training method.
[0053] The method for training a proprietary word translation model provided by an embodiment of the present invention obtains first source language data, generates a random number corresponding to the first source language data according to a preset distribution probability, adds pre-generated random noise to the first source language data according to the random number and a preset threshold value, obtains a training data set, and trains a preset machine translation model according to the training data set and the target language data corresponding to the training data set to obtain a proprietary word translation model. In the present invention, the first source language data is judged, the first source language data is subjected to noise processing using pre-generated random noise, and the translation model is iteratively trained. By training the first source language data subjected to noise processing, more diverse data is processed in the model training, the robustness of the proprietary word translation model is improved, and the probability of translation errors caused by mismatches in the proprietary word translation model in actual use is greatly reduced, thereby improving the translation effect of the proprietary word translation model. BRIEF DESCRIPTION OF THE DRAWINGS
[0054] 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 some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0055] Figure 1 One of the step flow charts of the method for training a proper word translation model provided by an embodiment of the present invention;
[0056] Figure 2 yes Figure 1 A method flow chart of step 103 of the method for training a special word translation model of a power regulation method provided by an embodiment of the present invention;
[0057] Figure 3 This is the second step flow chart of the method for training a proper word translation model provided by an embodiment of the present invention;
[0058] Figure 4 This is the third step flow chart of the method for training a proprietary word translation model provided by an embodiment of the present invention;
[0059] Figure 5 Schematic diagram of the structure of a proper word translation model training device provided by an embodiment of the present invention;
[0060] Figure 6 It is a structural schematic diagram of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0061] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0062] Reference Figure 1 , shows one of the step flow charts of the method for training a proper word translation model provided by an embodiment of the present invention, the method may include:
[0063] Step 101: Acquire first source language data, and generate a random number corresponding to the first source language data according to a preset probability distribution.
[0064] In an embodiment of the present invention, in order to improve the accuracy of the machine translation model for the translation of special words, a special word translation model is obtained by training a preset machine translation model. In the process of model training, it is first necessary to obtain a training data set, that is, first obtain the first source language data, pre-process the first source language data, and generate a random number corresponding to the first source language data according to a preset probability distribution. In this embodiment, the electronic device can directly obtain the first source language data to be translated from the corpus at the input end, or obtain the first source language data to be translated by manual collection. The first source language data is the source language data to be translated at the input end of the preset machine translation model, including input end sentences, words or phrases.
[0065] It should be noted that in order to iteratively train the preset machine translation model to improve the effect of the preset machine translation model and thereby achieve accurate translation of proprietary words, a large amount of first source language data needs to be obtained for processing as training data. The more training data there is, the better the model effect obtained by the final training will be.
[0066] Specifically, in order to improve the translation effect of the model, the embodiment of the present application performs data enhancement at the data level. By acquiring the first source language data, a random number corresponding to the first source language data is generated according to a preset distribution probability, and the first source language data is preprocessed so that the preprocessed first source language data is subjected to conditional judgment to determine whether to add noise to the first source language data. In some possible embodiments, the first source language data is preprocessed to obtain the preprocessed random number. The preset probability distribution can adopt a 0-1 distribution to generate a random number corresponding to the first source language data. For example, the first source language is a Chinese sentence "Xiao Liu is very happy". A random number is generated according to the character string and distribution algorithm of the sentence. In this embodiment, the first source language data is converted into a random number representation to facilitate further judgment of the first source language data.
[0067] In the embodiment of the present application, since the purpose of training the translation model is to use the translation model for accurate translation between any pair of languages, the above-mentioned first source language data can refer to the source language sentence, and the translation information of the first source language data can refer to the target language sentence. Accordingly, the proprietary word translation model finally trained can perform proprietary word translation on the first source language data.
[0068] Step 102: Add pre-generated random noise to the first source language data according to the random number and the preset threshold value to obtain a training data set.
[0069] It should be noted that adding noise increases the difficulty of network training and achieves a certain regularization effect, so that the output of the model does not flip when the input is superimposed with noise, resists the attack of adversarial samples, and also has a certain effect of improving the generalization ability of the model. In the embodiment of the present invention, there are many ways to inject noise into the preset machine translation model, such as through the input layer, hidden layer, weight, output layer, etc. In this embodiment, adding noise to the input layer of the translation model for the enhancement of the first source language data is essentially a regularization because the neural network is not robust to noise, and the robustness of the proprietary word translation model is improved by mixing noise and then training.
[0070] In an embodiment of the present invention, a pre-generated random noise is added to the first source language data according to a random number corresponding to the first source language data and a preset threshold value to obtain a training data set. Specifically, the preset threshold value is set according to the training requirements of the machine translation model, and is used to determine whether to perform noise processing on the first source language data according to the random number of the first source language data. Random noise is a type of noise generated by the accumulation of a large number of fluctuations randomly generated in time. In this embodiment, the random noise is accumulated according to the translation process of a large amount of source language data, and mainly includes two types, one is to randomly select a preset number of first word tokens from the corresponding word tokens of the target language data on the target end, and the other is to randomly rearrange and randomly select a preset number of second word tokens from the corresponding word tokens of the target language data on the target end.
[0071] Specifically, step 102 adds pre-generated random noise to the first source language data according to a random number and a preset threshold to obtain a training data set, which may include the following steps:
[0072] If the random number is less than or equal to a preset threshold, it is determined to add the pre-generated random noise to the first source language data, and the processed first source language data is stored in the training data set; if the random number is greater than the preset threshold, the first source language data is stored in the training data set.
[0073] Specifically, since the random noise in this embodiment includes two types, the random noise is composed of word tokens randomly selected from the vocabulary of the target language, wherein the target language vocabulary is a collection of word tokens contained in all target sentences. In this embodiment, the random noise includes randomly selecting a preset number of first word tokens from the word tokens corresponding to the target language data of the target end, and randomly rearranging and randomly selecting a preset number of second word tokens from the word tokens corresponding to the target language data of the target end. After determining the random noise, according to the random condition of the random noise, when the random condition of the random noise is met, a training data set is obtained; when the random condition is not met, the word tokens of the obtained random length number are directly spliced to the first source language data to obtain a training data set.
[0074] Therefore, in this embodiment, if the random number is less than or equal to the preset threshold, determining to add the pre-generated random noise to the first source language data, and storing the processed first source language data in the training data set includes:
[0075] If the preset random condition is met, the pre-generated random noise is added to the first source language data to obtain a training data set, which includes: a preset number of first word tokens randomly selected from the corresponding word tokens of the target language data on the target end are spliced after the first source language data, and a preset number of second word tokens randomly selected from the corresponding word tokens of the target language data on the target end are spliced after the first source language data by random rearrangement.
[0076] If the preset random condition is not met, the word tokens of the obtained random length are concatenated to the first source language data and stored in the training data set.
[0077] It should be noted that the training data set obtained in the embodiment of the present invention includes the first source language data and the first source language data after adding the pre-generated random noise. In this embodiment, it is determined whether to pre-process the first source language data, that is, whether to add random noise to the first source language data, based on the comparison and judgment between the random number of the first source language data and the preset threshold.
[0078] It should be noted that in the embodiment of the present invention, noise can be added to the first source language data by sentence-end splicing to construct training data for a proprietary word translation model. For example, since there are two types of random noise, training data with noise added is generated when the conditions are met, and no noise is added when the conditions are not met. Then, according to the preset random conditions of the random noise, the obtained training data set includes: unprocessed first source language data, first source language data with first word tokens spliced, first source language data with second word tokens spliced, and first source language data with word tokens of a random length obtained by directly splicing.
[0079] In an embodiment of the present invention, pre-generated random noise is added to the first source language data through the conditions of a random number and a preset threshold to obtain a training data set, and the first source language data that meets the conditions is mixed with noise and then trained to improve the robustness of the proprietary word translation model.
[0080] Step 103: training a preset machine translation model according to the training data set and the target language data corresponding to the training data set to obtain a special word translation model.
[0081] The embodiment of the present invention trains a proprietary word translation model based on training data, and specifically trains a preset machine translation model through a training data set and target language data corresponding to the training data set. In this embodiment, the first translation data output by the preset machine translation model based on the training data set can be obtained; a loss function value is generated based on the first translation data and the target language data; and the model parameters and the training data set of the preset machine translation model are iteratively adjusted based on the loss function value until the proprietary word translation convergence condition is met, thereby obtaining a trained proprietary word translation model.
[0082] The method for training a proprietary word translation model provided by an embodiment of the present invention obtains first source language data, generates a random number corresponding to the first source language data according to a preset distribution probability, adds pre-generated random noise to the first source language data according to the random number and a preset threshold value, obtains a training data set, and trains a preset machine translation model according to the training data set and the target language data corresponding to the training data set to obtain a proprietary word translation model. In the present invention, the first source language data is judged, the first source language data is subjected to noise processing using pre-generated random noise, and the translation model is iteratively trained. By training the first source language data subjected to noise processing, more diverse data is processed in the model training, the robustness of the proprietary word translation model is improved, and the probability of translation errors caused by mismatches in the proprietary word translation model in actual use is greatly reduced, thereby improving the translation effect of the proprietary word translation model.
[0083] Further, refer to Figure 2 , Figure 2 yes Figure 1 The method flow chart of step 103 of the method for training a proper word translation model provided in the embodiment of the present invention, step 103 comprises:
[0084] Step 1031: Obtain first translation data output by a preset machine translation model according to a training data set.
[0085] Specifically, under the framework of the preset machine translation model, the corresponding output result obtained by translating the training data set is obtained, and the first translation data is the translation result of the training data set after the preset machine translation model, so as to adjust the obtained training data set and training model according to the difference between the first translation data and the standard translation.
[0086] Step 1032: Generate a loss function value according to the first translation data and the target language data.
[0087] In this embodiment, the loss function is not specifically limited. The target language data is the translation data at the output end of the translation model, corresponding to the data to be translated at the input end. The target language data is used as a reference in the embodiment of the present invention to generate the loss function value of the translation model.
[0088] Step 1033, iteratively adjust the model parameters and training data set of the preset machine translation model according to the loss function value.
[0089] Specifically, the preset machine translation model in this embodiment is a neural network translation model. In iterative training, the model parameters and training data set of the preset machine translation model are adjusted according to the loss function value, wherein the model parameters include parameters such as training rate, dynamic coefficient, and allowable loss. In this embodiment, the training rate of the proprietary word translation model is determined by experience. The larger the training rate, the greater the weight change and the faster the convergence. However, if the training rate is too large, it will cause oscillation of the training system, that is, the larger the training rate is, the better it is without causing oscillation. Therefore, the training rate will be automatically adjusted, and the optimal value is adjusted to 0.9. In addition, the dynamic coefficient of the model is also empirical and can be set to any parameter of 0.6 to 0.8. The allowable loss during the training process is generally taken as 0.001 to 0.00001. When the error of multiple iteration results is less than this value, the system ends the iterative calculation and gives the result. Since the neural network calculation cannot guarantee the convergence of the iteration results under various parameter configurations, when the iteration results do not converge, the maximum number of iterations is allowed.
[0090] Step 1034: If the adjustment is made to meet the convergence condition of the proprietary word translation, a trained proprietary word translation model is obtained.
[0091] It should be noted that convergence refers to the state in which the gradient change of the model tends to be flat during the training process. When the model meets the convergence conditions, the training is completed.
[0092] In the embodiment of the present invention, the first translation data outputted by the preset machine translation model according to the training data set is obtained, and the loss function value is generated according to the first translation data and the target language data, and the model parameters of the preset machine translation model and the training data set are iteratively adjusted according to the loss function value. If the adjustment is made to meet the convergence condition of the proprietary word translation, the trained proprietary word translation model is obtained. That is, the training data set is used to iteratively train the translation model, and the first source language data with noise processing is trained to process more diverse data in the model training, and the optimized proprietary word translation model is obtained by adjusting the parameters, which greatly reduces the probability of translation errors caused by the wrong matching of the proprietary word translation model in actual use.
[0093] Reference Figure 3 , shows a second step flow chart of the method for training a proper word translation model provided by an embodiment of the present invention, the method may include:
[0094] Step 104: Generate a random length number of a word token according to the first source language data and a preset probability distribution.
[0095] Step 105, obtaining a word token of a random length according to the random length.
[0096] Step 106 : generating random noise according to the acquired word tokens when a preset random condition is met.
[0097] The random noise includes randomly selecting a preset number of first word tokens from the word tokens corresponding to the target language data on the target end and randomly rearranging and randomly selecting a preset number of second word tokens from the word tokens corresponding to the target language data on the target end.
[0098] It should be noted that the preset random condition is a generation condition pre-set according to the content of the first source language data, and the acquired word tokens are processed to generate random noise. This embodiment does not limit the preset random condition. In actual use, the preset random condition can be any condition that can uniquely indicate the generation of random noise.
[0099] In steps 104-106 of this embodiment, a random length number of word tokens is generated according to the first source language data and a preset probability distribution, and a word token of a random length number is obtained according to the random length number. When a preset random condition is met, random noise is generated according to the obtained word tokens, which can further realize the processing of the first source language data. Specifically, the random noise is generated according to the first source language data and a preset probability distribution. The random length number of word tokens can be generated according to the Poisson distribution, and the corresponding number of word tokens are obtained from the vocabulary corresponding to the target end sentence to form the random noise. Of course, the above is only a specific example. In actual use, other probability distribution methods can also be used to generate random word token lengths, which will not be described one by one here.
[0100] It should be noted that the present embodiment does not limit the specific execution location of steps 104-106. In the present embodiment, for ease of understanding, the execution of steps 104-106 before step 101 is used as an example for description. In actual use, steps 104-106 can also be completed as a step before step 102, and each case will not be described one by one here.
[0101] Compared with the prior art, in order to process the first source language data to obtain training data, the embodiment of the present invention obtains word tokens in advance to generate random noise, and performs noise processing on the first source language data, thereby iteratively training the translation model. The noise addition adopted by the present invention enables more diverse data to be processed in model training, improves the robustness of the proprietary word translation model, and greatly reduces the probability of translation errors caused by incorrect matching in actual use of the proprietary word translation model.
[0102] Reference Figure 4, shows a third step flow chart of the method for training a proper word translation model provided by an embodiment of the present invention, the method may include:
[0103] Step 107 , based on the trained proprietary word translation model and according to the correspondence between the input-end proprietary words and the target-end proprietary words, add the target-end proprietary words to the first source language data at the input end.
[0104] Specifically, according to the trained proprietary word translation model and the correspondence between the input-end proprietary words and the target-end proprietary words, the target-end proprietary words are added to the first source language data at the input end. Since the trained proprietary word translation model already has a large amount of experience in translating the first source language data with noise added, after receiving the first source language data with the target-end proprietary words added, the proprietary word translation model can translate the input sentence into the target language sentence while translating the vocabulary or phrases in the input sentence into the specified target-end vocabulary or phrases, thereby achieving the accurate translation effect of the proprietary word translation model.
[0105] Step 108: output the target language data corresponding to the first source language data including the target-side proper word.
[0106] Compared with the prior art, the embodiment of the present invention adds the target end proprietary words to the first source language data of the input end based on the correspondence between the input end proprietary words and the target end proprietary words, and outputs the target language data corresponding to the first source language data including the target end proprietary words. Thus, the purpose of playing the video ringback tone on the peripheral terminal is achieved, the problem of the prior art proprietary word translation model causing translation errors after mismatching in actual use is solved, and the accurate translation effect of the proprietary word translation model is improved.
[0107] Reference Figure 5 , shows a schematic diagram of the structure of a device for training a proper word translation model provided by an embodiment of the present invention, the device may include:
[0108] The data acquisition module 201 is used to acquire first source language data and generate a random number corresponding to the first source language data according to a preset distribution probability;
[0109] A data processing module 202, configured to add pre-generated random noise to the first source language data according to the random number and a preset threshold value to obtain a training data set;
[0110] The model training module 203 is used to train a preset machine translation model according to the training data set and the target language data corresponding to the training data set to obtain the special word translation model.
[0111] Optionally, the data processing module 202 includes:
[0112] A first data processing submodule, configured to determine to add pre-generated random noise to the first source language data if the random number is less than or equal to a preset threshold, and store the processed first source language data in the training data set;
[0113] The second data processing submodule is configured to store the first source language data into the training data set if the random number is greater than a preset threshold.
[0114] Optionally, the device further comprises:
[0115] A first generating module, configured to generate a random length number of a word token according to the first source language data and the preset probability distribution;
[0116] A second acquisition module is used to acquire a word token of a random length according to the random length;
[0117] The second generating module is used to generate random noise according to the acquired word tokens when a preset random condition is met; wherein the random noise includes randomly selecting a preset number of first word tokens from the word tokens corresponding to the target language data on the target end and randomly rearranging and randomly selecting a preset number of second word tokens from the word tokens corresponding to the target language data on the target end.
[0118] Optionally, the first data processing submodule includes:
[0119] A first data processing subunit is configured to add pre-generated random noise to the first source language data if a preset random condition is met, so as to obtain the training data set, wherein the training data set includes: a preset number of first word tokens randomly selected from the corresponding word tokens of the target language data at the target end are spliced after the first source language data, and a preset number of second word tokens randomly selected from the corresponding word tokens of the target language data at the target end are spliced after the first source language data;
[0120] The second data processing subunit is used for concatenating the word tokens of the obtained random length to the first source language data and storing them in the training data set if the preset random condition is not met.
[0121] Optionally, the model training module 203 includes:
[0122] An acquisition submodule, configured to acquire first translation data output by the preset machine translation model according to the training data set;
[0123] A third generating submodule, configured to generate a loss function value according to the first translation data and the target language data;
[0124] An adjustment submodule, used for iteratively adjusting the model parameters of the preset machine translation model and the training data set according to the loss function value;
[0125] The training submodule is used to obtain the trained proprietary word translation model if the proper word translation convergence condition is satisfied.
[0126] Optionally, the device further includes:
[0127] A translation module, configured to add the target-side proprietary words to the first source language data at the input end based on the trained proprietary word translation model and according to the correspondence between the input-side proprietary words and the target-side proprietary words;
[0128] The output module is used to output the target language data corresponding to the first source language data including the target-side specific words.
[0129] The proprietary word translation model training device provided by the embodiment of the present invention obtains the first source language data, generates a random number corresponding to the first source language data according to a preset distribution probability; adds the pre-generated random noise to the first source language data according to the random number and the preset threshold value to obtain a training data set, and trains the preset machine translation model according to the training data set and the target language data corresponding to the training data set to obtain the proprietary word translation model. In the present invention, the first source language data is judged, the first source language data is subjected to noise processing using the pre-generated random noise, and the translation model is iteratively trained. By training the first source language data subjected to noise processing, more diverse data is processed in the model training, the robustness of the proprietary word translation model is improved, and the probability of translation errors caused by the wrong matching of the proprietary word translation model in actual use is greatly reduced, thereby improving the translation effect of the proprietary word translation model.
[0130] The embodiment of the present invention further provides an electronic device, such as Figure 6 As shown, it includes a processor 301, a communication interface 302, a memory 303 and a communication bus 304, wherein the processor 301, the communication interface 302, and the memory 303 communicate with each other through the communication bus 304.
[0131] Memory 303, used for storing computer programs;
[0132] The processor 301, when used to execute the program stored in the memory 303, can implement the following steps:
[0133] Acquire first source language data, and generate a random number corresponding to the first source language data according to a preset distribution probability; add pre-generated random noise to the first source language data according to the random number and a preset threshold value to obtain a training data set; train a preset machine translation model according to the training data set and the target language data corresponding to the training data set to obtain a proprietary word translation model.
[0134] The communication bus mentioned in the above terminal can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The communication bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus.
[0135] The communication interface is used for communication between the above terminal and other devices.
[0136] The memory may include a random access memory (RAM) or a non-volatile memory, such as at least one disk memory. Optionally, the memory may also be at least one storage device located away from the aforementioned processor.
[0137] The above-mentioned processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components.
[0138] The present invention also provides a readable storage medium. When the instructions in the storage medium are executed by a processor of an electronic device, the electronic device can execute the proper word translation model training method of the aforementioned embodiment.
[0139] As for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0140] The algorithm and display provided herein are not inherently related to any particular computer, virtual system or other equipment. According to the above description, it is obvious that the structure required for constructing such a system is. In addition, the present invention is not directed to any specific programming language either. It should be understood that various programming languages can be utilized to realize the content of the present invention described herein, and the description of the above specific language is for disclosing the best mode of the present invention.
[0141] In the description provided herein, a large number of specific details are described. However, it is understood that embodiments of the present invention can be practiced without these specific details. In some instances, well-known methods, structures and techniques are not shown in detail so as not to obscure the understanding of this description.
[0142] Similarly, it should be understood that in order to streamline the present invention and aid in understanding one or more of the various inventive aspects, in the above description of exemplary embodiments of the present invention, various features of the present invention are sometimes grouped together into a single embodiment, figure, or description thereof. However, this disclosed method should not be interpreted as reflecting the following intention: that the claimed invention requires more features than those expressly recited in each claim. Rather, as reflected in the claims below, inventive aspects lie in less than all of the features of the individual embodiments disclosed above. Therefore, the claims that follow the detailed description are hereby expressly incorporated into the detailed description, with each claim itself serving as a separate embodiment of the present invention.
[0143] Those skilled in the art will appreciate that the modules in the devices in the embodiments may be adaptively changed and arranged in one or more devices different from the embodiments. The modules or units or components in the embodiments may be combined into one module or unit or component, and in addition they may be divided into a plurality of submodules or subunits or subcomponents. Except that at least some of such features and / or processes or units are mutually exclusive, all features disclosed in this specification (including the accompanying claims, abstracts and drawings) and all processes or units of any method or device disclosed in this manner may be combined in any combination. Unless otherwise expressly stated, each feature disclosed in this specification (including the accompanying claims, abstracts and drawings) may be replaced by an alternative feature providing the same, equivalent or similar purpose.
[0144] The various component embodiments of the present invention may be implemented in hardware, or in software modules running on one or more processors, or in a combination thereof. It should be understood by those skilled in the art that a microprocessor or digital signal processor (DSP) may be used in practice to implement some or all of the functions of some or all of the components in the sorting device according to the present invention. The present invention may also be implemented as a device or apparatus program for executing part or all of the methods described herein. Such a program for implementing the present invention may be stored on a computer-readable medium, or may be in the form of one or more signals. Such a signal may be downloaded from an Internet website, or provided on a carrier signal, or provided in any other form.
[0145] It should be noted that the above embodiments illustrate the present invention rather than limit it, and that those skilled in the art may devise alternative embodiments without departing from the scope of the appended claims. In the claims, any reference symbol between brackets shall not be construed as a limitation on the claims. The word "comprising" does not exclude the presence of elements or steps not listed in the claims. The word "one" or "an" preceding an element does not exclude the presence of a plurality of such elements. The present invention may be implemented by means of hardware comprising a number of different elements and by means of a suitably programmed computer. In a unit claim enumerating a number of devices, several of these devices may be embodied by the same hardware item. The use of the words first, second, and third, etc., does not indicate any order. These words may be interpreted as names.
[0146] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0147] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included in the protection scope of the present invention.
[0148] The above is only a specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any person skilled in the art can easily think of changes or substitutions within the technical scope disclosed by the present invention, which should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention should be based on the protection scope of the claims.
[0149] It should be noted that the various data-related processes in the embodiments of the present application are all carried out in compliance with the corresponding data protection laws and policies of the country where the device is located, and with the authorization given by the owner of the corresponding device.
Claims
1. A method for training a proprietary word translation model, characterized in that: The method comprises: Acquire first source language data, and generate a random number corresponding to the first source language data according to a preset probability distribution; Generating a random length number of word tokens according to the first source language data and the preset probability distribution; According to the random length number, obtaining a word token of the random length number; When a preset random condition is met, generating random noise according to the acquired word token; According to the random number and the preset threshold, pre-generated random noise is added to the first source language data to obtain a training data set; wherein the random noise includes randomly selecting a preset number of first word tokens from the corresponding word tokens of the target language data on the target end, and randomly rearranging and randomly selecting a preset number of second word tokens from the corresponding word tokens of the target language data on the target end; The preset machine translation model is trained according to the training data set and the target language data corresponding to the training data set to obtain the special word translation model.
2. The method according to claim 1, characterized in that: The step of adding pre-generated random noise to the first source language data according to the random number and a preset threshold value to obtain a training data set includes: If the random number is less than or equal to a preset threshold, determining to add pre-generated random noise to the first source language data, and storing the processed first source language data in the training data set; If the random number is greater than the preset threshold, the first source language data is stored in the training data set.
3. The method according to claim 1, characterized in that The step of adding pre-generated random noise to the first source language data according to the random number and a preset threshold value to obtain a training data set includes: If the preset random condition is met, pre-generated random noise is added to the first source language data to obtain the training data set, the training data set comprising: a preset number of first word tokens randomly selected from the corresponding word tokens of the target language data on the target end are spliced after the first source language data, and a preset number of second word tokens randomly selected from the corresponding word tokens of the target language data on the target end are spliced after the first source language data by random rearrangement; If the preset random condition is not met, the word tokens of the obtained random length are concatenated to the first source language data and stored in the training data set.
4. The method according to claim 1, characterized in that: The step of training a preset machine translation model according to the training data set and the target language data corresponding to the training data set to obtain the special word translation model includes: Acquire first translation data output by the preset machine translation model according to the training data set; generating a loss function value according to the first translation data and the target language data; Iteratively adjusting the model parameters of the preset machine translation model and the training data set according to the loss function value; If the adjustment is made to satisfy the convergence condition of the proprietary word translation, the trained proprietary word translation model is obtained.
5. The method according to claim 1, characterized in that After training a preset machine translation model according to the training data set and the target language data corresponding to the training data set to obtain the special word translation model, the method further includes: Based on the trained special word translation model, according to the correspondence between the input-end vocabulary or phrase and the target-end vocabulary or phrase, adding the target-end special word to the first source language data at the input end; Output the target language data corresponding to the first source language data including the target-side specific words.
6. A device for training a proprietary word translation model, characterized in that: The device comprises: A data acquisition module, configured to acquire first source language data and generate a random number corresponding to the first source language data according to a preset probability distribution; A first generating module, configured to generate a random length number of a word token according to the first source language data and the preset probability distribution; A second acquisition module is used to acquire a word token of a random length according to the random length; A second generating module, configured to generate random noise according to the acquired word tokens when a preset random condition is met; A data processing module, configured to add pre-generated random noise to the first source language data according to the random number and a preset threshold value to obtain a training data set; wherein the random noise includes randomly selecting a preset number of first word tokens from the corresponding word tokens of the target language data at the target end, and randomly rearranging and randomly selecting a preset number of second word tokens from the corresponding word tokens of the target language data at the target end; The model training module is used to train a preset machine translation model according to the training data set and the target language data corresponding to the training data set to obtain the special word translation model.
7. The device according to claim 6, characterized in that The data processing module comprises: A first data processing submodule, configured to determine to add pre-generated random noise to the first source language data if the random number is less than or equal to a preset threshold, and store the processed first source language data in the training data set; The second data processing submodule is configured to store the first source language data into the training data set if the random number is greater than the preset threshold.
8. An electronic device, characterized in that: include: A processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the processor implements the method for training a proper word translation model as described in any one of claims 1 to 5 when executing the program.
9. A readable storage medium, characterized in that: When the instructions in the storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute the proper word translation model training method described in any one of claims 1-5.
