Neural machine translation model construction method and device, translation method and device

By generating attribute vector pairs corresponding to target words in the neural machine translation model, the problem of out-of-set words is solved, the quality and efficiency of translation are improved, and it is suitable for offline translation systems of mobile terminals.

CN111104806BActive Publication Date: 2024-09-20UNIV OF MACAU
View PDF 8 Cites 0 Cited by

Patent Information

Application Number
CN201811259546.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2018-10-26
Publication Date
2024-09-20
Estimated Expiration
2038-10-26

AI Technical Summary

Technical Problem

Due to limited computing resources, the existing neural machine translation system needs to limit the vocabulary, resulting in the problem of out-of-set words and the inability to effectively translate unregistered words. Moreover, the pre- and post-processing based on fine-grained translation models has the possibility of error propagation, which reduces the translation quality.

Method used

The neural machine translation model based on the encoder-decoder framework is used to generate a first attribute vector and a second attribute vector corresponding to the target vocabulary to form an attribute vector pair to represent the target vocabulary, avoiding pre- and post-processing and reducing the number of parameters. Improved translation efficiency.

Benefits of technology

It effectively solves the problem of foreign words, greatly improves the quality and efficiency of translation, and reduces the space consumption of the model. It is suitable for offline translation systems of mobile terminals.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN111104806B
    Figure CN111104806B
Patent Text Reader

Abstract

The embodiments of the present invention provide a method and device for constructing a neural machine translation model, and a translation method and device. The method for constructing a neural machine translation model includes: constructing a neural machine translation model based on an encoder-decoder framework, and when the decoder generates a target vocabulary, it sequentially generates a first attribute vector and a second attribute vector corresponding to the target vocabulary, and then maps the attribute vector pair composed of the first attribute vector and the second attribute vector to the corresponding target vocabulary. The method and device for constructing a neural machine translation model, and the translation method and device provided by the embodiments of the present invention can cover as many target vocabulary as possible by using a pair of attribute vectors to represent the target vocabulary, and there is no need to pre- and post-process the training and test data, thus avoiding error propagation, and can effectively solve the problem of out-of-set words in neural machine translation; in addition, since the number of parameters used to represent the target vocabulary is greatly reduced, the space consumption of the model is also reduced accordingly.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present invention relate to the technical field of natural language processing and conversion, and specifically to a method and device for constructing a neural machine translation model, and a translation method and device. Background Art

[0002] Machine translation refers to the process of using a machine to automatically convert a natural language (hereinafter referred to as the source language) into another language with the same meaning (hereinafter referred to as the target language). With the acceleration of globalization, the political, economic, and cultural exchanges between people of different languages ​​are increasing day by day, and people's demand for translation is becoming increasingly urgent. Automatic machine translation has played a huge role in promoting communication between people of different languages ​​due to its simplicity and efficiency.

[0003] With the development of deep learning technology, neural machine translation based on the encoder-decoder framework has become a new generation of machine translation technology. In public evaluations of machine translation in multiple language pairs, neural machine translation has greatly improved translation quality compared to other machine translation methods. Google, Baidu and many other companies have successively upgraded their online machine translation systems in multiple language pairs to neural machine translation.

[0004] However, due to the limitation of computer resources, especially memory size, the existing neural machine translation system needs to limit its vocabulary, which leads to the emergence of the out-of-set word problem. In the process of decoding and generating each word, the neural machine translation model needs to normalize the probabilities of all target words and select the word with the highest probability, so the time complexity is very high. For the above reasons, the most widely used method is to divide the words according to their frequency of occurrence in the training set, select the words with higher frequency (high-frequency words) and add them to the vocabulary, and treat the other words as unregistered words. Therefore, neural machine translation cannot translate unregistered words well, which leads to the emergence of the out-of-set word problem.

[0005] At present, the main method to solve the problem of out-of-set words is to use a fine-grained translation model, which divides some complex words into multiple simple sub-words according to certain rules, such as dividing the English word "enjoying" into two sub-words, "enjoy" and "ing". Before training, all complex words in the training corpus are divided into multiple simple sub-words, that is, pre-processing; after the model training is completed, the multiple simple sub-words in the translated sentences are reassembled into normal words, that is, post-processing. Among them, the segmentation rules for dividing words into sub-words are learned in the training set through a statistical method called byte pair encoding (BPE). There are often cases where complex words are segmented incorrectly, such as the word "fling" is incorrectly segmented into two sub-words, "fl" and "ing". If the neural machine translation model is trained in this case, because the input training data is wrong, error propagation will occur.

[0006] Therefore, the use of fine-grained translation models is mainly based on statistical and rule-based pre-processing and post-processing operations, and the translation model itself is not improved. There is a possibility of error propagation, which in turn reduces the translation quality and cannot effectively solve the out-of-text problem.

[0007] In summary, the problem of limited vocabulary in neural machine translation remains to be solved. How to cover as much target language vocabulary as possible without increasing the model space complexity and computational complexity, thereby improving the quality of translation has become an important research topic in neural machine translation. Summary of the invention

[0008] In order to solve the problem of out-of-text words in existing neural machine translation, embodiments of the present invention provide a method and device for constructing a neural machine translation model, and a translation method and device.

[0009] In a first aspect, an embodiment of the present invention provides a method for constructing a neural machine translation model, the method comprising: constructing a neural machine translation model based on an encoder-decoder framework, the neural machine translation model comprising an encoder and a decoder; wherein, when generating a target vocabulary, the decoder sequentially generates a first attribute vector and a second attribute vector corresponding to the target vocabulary, and then the first attribute vector and the second attribute vector form an attribute vector pair mapped to the corresponding target vocabulary.

[0010] In a second aspect, an embodiment of the present invention provides a neural machine translation method, the method comprising: translating a source sentence into a target sentence based on a neural machine translation model constructed by the above method.

[0011] In a third aspect, an embodiment of the present invention provides a device for constructing a neural machine translation model, comprising: a neural machine translation model construction module, for constructing a neural machine translation model based on an encoder-decoder framework, the neural machine translation model comprising an encoder and a decoder; wherein, when generating a target vocabulary, the decoder sequentially generates a first attribute vector and a second attribute vector corresponding to the target vocabulary, and then the first attribute vector and the second attribute vector form an attribute vector pair mapped to the corresponding target vocabulary.

[0012] In a fourth aspect, an embodiment of the present invention provides a neural machine translation device, including: a translation module, used to translate a source sentence into a target sentence based on the neural machine translation model constructed according to the above embodiment.

[0013] In a fifth aspect, an embodiment of the present invention provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the method provided in the first aspect or the second aspect when executing the program.

[0014] In a sixth aspect, an embodiment of the present invention provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the method provided in the first aspect or the second aspect.

[0015] The neural machine translation model construction method and device, translation method and device provided in the embodiments of the present invention can cover as many target words as possible by using a pair of attribute vectors to represent the target words, and do not require pre- and post-processing of the training and test data, thereby avoiding error propagation and effectively solving the out-of-text word problem in neural machine translation, thereby greatly improving the translation quality and efficiency. In addition, since the number of parameters used to represent the target words is greatly reduced, the space consumption of the model is also reduced accordingly. BRIEF DESCRIPTION OF THE DRAWINGS

[0016] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. 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.

[0017] Figure 1 is a flow chart of a method for constructing a neural machine translation model provided by an embodiment of the present invention;

[0018] Figure 2 is a schematic diagram of the structure of a neural machine translation model constructed in the method for constructing a neural machine translation model provided in an embodiment of the present invention;

[0019] Figure 3 It is a schematic diagram of the mapping relationship between target vocabulary and attribute vector pairs in the method for constructing a neural machine translation model provided by an embodiment of the present invention;

[0020] Figure 4 is a flow chart of a neural machine translation method provided by an embodiment of the present invention;

[0021] Figure 5 Schematic diagram of the structure of a device for constructing a neural machine translation model provided by an embodiment of the present invention;

[0022] Figure 6 is a schematic diagram of the structure of a neural machine translation device provided by an embodiment of the present invention;

[0023] Figure 7 It is a schematic diagram of the physical structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0024] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings 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.

[0025] Figure 1 is a flow chart of a method for constructing a neural machine translation model provided by an embodiment of the present invention. Figure 1 As shown, the method includes:

[0026] Step 101: construct a neural machine translation model based on an encoder-decoder framework, wherein the neural machine translation model includes an encoder and a decoder; wherein, when generating a target vocabulary, the decoder sequentially generates a first attribute vector and a second attribute vector corresponding to the target vocabulary, and then forms an attribute vector pair composed of the first attribute vector and the second attribute vector and maps it to the corresponding target vocabulary.

[0027] A neural machine translation model is constructed based on an encoder-decoder framework, and the neural machine translation model includes an encoder and a decoder; wherein the encoder is not improved in the embodiment of the present invention, and any encoder in the prior art can be used in the embodiment of the present invention. The improvement of the embodiment of the present invention lies in the improvement of the decoder.

[0028] The decoder in the neural machine translation model constructed in the embodiment of the present invention adopts a hierarchical decoding method to decode and generate a target vocabulary. The hierarchical decoding method means that when the decoder generates a target vocabulary, it sequentially generates two attribute vectors (two layers) corresponding to the target vocabulary, namely a first attribute vector and a second attribute vector, and then these two attribute vectors form an attribute pair mapped to the corresponding target vocabulary.

[0029] In the embodiment of the present invention, the neural machine translation model is used to translate a source language into a target language, and the result obtained by translating the source language is composed of target words in the target language.

[0030] Before translation, a mapping relationship is established between the target vocabulary in the target language and the first attribute vector and the second attribute vector. Therefore, after obtaining the first attribute vector and the second attribute vector corresponding to the target vocabulary, the target vocabulary can be obtained through the mapping relationship.

[0031] When generating the target vocabulary, the decoder generates the first attribute vector and the second attribute vector corresponding to the target vocabulary in sequence according to the decoding order. For example, when translating the text "Welcome to Beijing, China!" in the source language into "Welcome to Beijing, China!", the first attribute vector and the second attribute vector corresponding to "Welcome" are generated first, and then the first attribute vector and the second attribute vector corresponding to "to" are generated, and so on. After generating the first attribute vector and the second attribute vector of all the target vocabulary, the corresponding target vocabulary is obtained through the mapping relationship.

[0032] Due to the limitation of computing resources, the traditional neural machine translation method can only select some words with higher frequency in a vocabulary for training, which causes the problem of out-of-set words. For example, there are 1 million target words in the training set. Due to the limited computing resources, the traditional method can only select 30,000 to 80,000 target words with the highest frequency for training, and the rest are out-of-set words. However, for the neural machine translation model constructed by the embodiment of the present invention, 1 million target words only need 1,000 first attribute vectors and 1,000 second attribute vectors to represent, so the method provided by the embodiment of the present invention can efficiently use 1 million target words for training, which solves the problem of out-of-set words in neural machine translation.

[0033] The embodiment of the present invention uses a pair of attribute vectors to represent the target vocabulary, which can cover as much target vocabulary as possible. There is no need to perform pre- and post-processing on the training and test data, thus avoiding error propagation. It can effectively solve the out-of-text word problem in neural machine translation, thereby greatly improving the translation quality and efficiency. In addition, since the number of parameters used to represent the target vocabulary is greatly reduced, the space consumption of the model is also reduced accordingly.

[0034] Figure 2 Schematic diagram of the structure of the neural machine translation model constructed in the method for constructing a neural machine translation model provided in an embodiment of the present invention. Figure 2 The method for constructing a neural machine translation model provided in an embodiment of the present invention and the characteristics of the constructed neural machine translation model are further explained.

[0035] Figure 2 The encoder in is a bidirectional recurrent neural network. It should be noted that Figure 2 The structure of the encoder shown in is only an example of the structure of the encoder in the neural machine translation model constructed by the embodiment of the present invention. The neural machine translation model constructed by the embodiment of the present invention may also adopt other types of encoders.

[0036] like Figure 2 As shown, the input of the encoder is the word vector of each word in the source sentence, and its output is represented as a hidden state sequence:

[0037] h=(h1,...,h I )

[0038] For example, input "Welcome to Beijing, China! <eos>", then the subscript of China is 1, <eos>The subscript is 6, and the capital I represents the length of the sentence, which is the subscript of the last word. <eos>It is a symbol that indicates the end of a sentence.

[0039] α is the attention function, the input is the hidden state sequence h, and the output is the context vector c.

[0040] The decoder uses a unidirectional recurrent neural network. When generating a target word, the decoder sequentially generates a first attribute vector and a second attribute vector corresponding to the target word, specifically including:

[0041] Obtaining the first attribute hidden state of the current target vocabulary through the hidden state sequence of the source sentence, the context vector corresponding to the current target vocabulary, the second attribute hidden state of the previous target vocabulary of the current target vocabulary, and the second attribute vector;

[0042] The calculation process can be done using the following formula:

[0043]

[0044]

[0045]

[0046] Where GRU(·) is the gated recurrent unit GRU function, ATT(·) is the attention mechanism function, and are the second attribute hidden state and second attribute vector of the generated previous word (j-1th word), is an intermediate variable in the model calculation process, h represents the hidden state sequence of the source sentence, c j Represents the context vector corresponding to the current target vocabulary (the jth word), reflecting the correspondence between the current target vocabulary and each word in the source sentence. Represents the first attribute hidden state of the current target word (the jth word);

[0047] Among them, when the subscript j-1 is 0, the corresponding parameter value is empty.

[0048] Obtaining a second attribute hidden state of the current target vocabulary through a context vector corresponding to the current target vocabulary, a first attribute hidden state of the current target vocabulary, and the first attribute vector;

[0049] The calculation process can be done using the following formula:

[0050]

[0051]

[0052] in and are the first attribute hidden state and first attribute vector of the current target vocabulary (the jth word), c j Represents the context vector corresponding to the current target vocabulary (the jth word); is an intermediate variable in the model calculation process. is the second attribute hidden state of the current target vocabulary (the jth word).

[0053] Calculate the probability of the current word corresponding to each first attribute vector based on the first attribute hidden state of the current target word;

[0054] The calculation of the probability of the current target vocabulary corresponding to each first attribute vector based on the first attribute hidden state of the current target vocabulary can be implemented by the following formula:

[0055]

[0056]

[0057] in, represents the probability of the first attribute vector of the mth row in the first real number matrix corresponding to the jth target word; represents the first attribute vector of the mth row in the first real number matrix; It is an intermediate variable in the calculation process; represents the first attribute vector of the i-th row in the first real number matrix; W (1) is a model training parameter for training the first attribute vector, and M is the number of rows of the first real number matrix; is the first attribute hidden state of the jth target word; is the second attribute vector of the j-1th target word; c j is the context vector of the jth target word; tanh(·) is the hyperbolic tangent function.

[0058] Calculate the probability of the current target word corresponding to each second attribute vector based on the second attribute hidden state of the current target word;

[0059] The calculation of the probability of the current word corresponding to each second attribute vector based on the second attribute hidden state of the current target word can be implemented by the following formula:

[0060]

[0061]

[0062] in, represents the probability of the second attribute vector of the nth row in the second real number matrix corresponding to the jth target word; represents the second attribute vector of the nth row in the second real number matrix; It is an intermediate variable in the calculation process; W represents the second attribute vector of the lth row in the second real number matrix; (2) is a model training parameter for training the second attribute vector, and N is the number of rows of the second real number matrix; is the second attribute hidden state of the j-th target word; is the first attribute vector of the jth target word; c j is the context vector of the jth target word; tanh(·) is the hyperbolic tangent function.

[0063] W (1) and W (2) The function is to linearly transform a vector into another vector, but the real values ​​in them are different and consist of different parameters. (1) and About W (2) and related.

[0064] According to the order of the target words, the first attribute vector and the second attribute vector of each target word are determined according to the calculated probabilities of all the target words corresponding to each first attribute vector and the probabilities of all the target words corresponding to each second attribute vector.

[0065] For each target word, the probability of the corresponding first attribute vector is calculated by the first attribute hidden state of the target word, and the first hidden state is related to the second attribute vector of the previous target word. This shows that the probability of the target word corresponding to the first attribute vector is related to the second attribute vector of the previous target word, that is, the probability of the corresponding first attribute vector and the probability of the corresponding second attribute vector of adjacent target words are not independent, but have a constraint relationship. If the probability value of a certain target word corresponding to a certain first attribute vector or second attribute vector is larger, it indicates that machine learning tends to select this attribute vector to achieve translation, and it also indicates that the translation may have greater accuracy when selecting this attribute vector. According to the order of the target words, the probability of all target words corresponding to each first attribute vector and the probability of each second attribute vector can be calculated. Under the constraint relationship of the attribute vectors corresponding to adjacent target words, the product of the probability of the first attribute vector corresponding to all target words and the probability of the second attribute vector can be calculated, and the first attribute vector and the second attribute vector corresponding to each target word when the product is the largest are taken as the first attribute vector and the second attribute vector corresponding to each target word finally determined.

[0066] Furthermore, when determining the first attribute vector and the second attribute vector of each target word, a preset number of first attribute vectors and second attribute vectors corresponding to each target word can be stored according to the probability, that is, a preset number of first attribute vectors and second attribute vectors corresponding to each target word with a higher probability are stored; under the constraint relationship of the attribute vectors corresponding to adjacent target words, the product of the probability of all target words corresponding to each first attribute vector and the probability of corresponding to each second attribute vector is calculated, and the first attribute vector and the second attribute vector corresponding to each target word when the product is the largest are taken as the first attribute vector and the second attribute vector corresponding to each target word finally determined. In this way, the computational complexity can be further reduced and the system operation efficiency can be improved.

[0067] After the first attribute vector and the second attribute vector corresponding to the target vocabulary are generated in sequence, an attribute vector pair composed of the first attribute vector and the second attribute vector is mapped to the corresponding target vocabulary.

[0068] The first attribute vector can be a row vector existing in the first real number matrix, and the second attribute vector can be a row vector existing in the second real number matrix. All target words in the target language have established mapping relationships with the first attribute vector and the second attribute vector. The mapping function from the target words to the first attribute vector and the second attribute vector can be represented by g. Conversely, g -1 It indicates the mapping relationship between the first attribute vector and the second attribute vector to obtain the corresponding target vocabulary. Figure 2 As shown, after obtaining the first attribute vector and the second attribute vector of each target word, through g -1 The corresponding target vocabulary is obtained through the mapping relationship.

[0069] The jth target word y j It can be expressed as:

[0070]

[0071] represents an attribute vector pair consisting of a first attribute vector in the mth row of the first real number matrix and a second attribute vector in the nth row of the second real number matrix.

[0072] The embodiment of the present invention uses a pair of attribute vectors to represent the target vocabulary, which can cover as much target vocabulary as possible. There is no need to perform pre- and post-processing on the training and test data, thus avoiding error propagation. It can effectively solve the out-of-text word problem in neural machine translation, thereby greatly improving the translation quality and efficiency. In addition, since the number of parameters used to represent the target vocabulary is greatly reduced, the space consumption of the model is also reduced accordingly.

[0073] Furthermore, based on the above embodiment, the method also includes training the neural machine translation model, specifically including: collecting preset features during the training of the neural machine translation model, and pausing the training when the model converges; remapping the target vocabulary and attribute vector pairs in the training set according to the collected preset features; continuing to train the neural machine translation model using the remapped attribute vector pairs; repeating the above steps until the training is terminated when a preset training time or number of training times is reached.

[0074] Preset features are collected during the training of the neural machine translation model. The preset features may be features that characterize the probability of attribute vector pairs corresponding to target vocabulary. Training is suspended when the model converges. The judgment condition for convergence of the neural machine translation model is that the cross entropy on the validation set no longer decreases after multiple model iterations. Suspending training means keeping all model parameters unchanged after a complete round of training.

[0075] After pausing the training, the target vocabulary and attribute vector pairs in the training set are remapped according to the collected preset features. The mapping relationship between the target vocabulary and the attribute vector pairs established at the beginning of the training is random and cannot achieve accurate translation well. With continuous training and learning, the mapping relationship between the target vocabulary and the attribute vector pairs is gradually reestablished to better achieve translation.

[0076] The neural machine translation model is continued to be trained using the remapped attribute vector pairs. The training parameters are related to the attribute vector pairs. When retraining, the model parameters after the training is paused are used, and the model is continued to be trained using the remapped attribute vector pairs.

[0077] Repeat the above steps, that is, repeatedly execute "collecting preset features during the training of the neural machine translation model, and pausing the training when the model converges; remapping the target vocabulary and attribute vector pairs in the training set according to the collected preset features; and continuing to train the neural machine translation model using the remapped attribute vector pairs", until the training is terminated when the preset training time or number of training times is reached.

[0078] On the basis of the above-mentioned embodiments, the embodiments of the present invention remap the target vocabulary and attribute vector pairs according to the collected preset features when the training is paused, and continue to train the neural machine translation model according to the remapped attribute vector pairs, so as to gradually optimize the mapping relationship between the target vocabulary and attribute vector pairs through learning, which is conducive to obtaining a more optimized neural machine translation model.

[0079] Further, based on the above embodiment, before training the neural machine translation model, the method also includes: establishing a first real number matrix and a second real number matrix respectively, the first real number matrix including a first attribute vector, and the second real number matrix including a second attribute vector; mapping the target vocabulary in the training set to a pair of initial first attribute vectors and second attribute vectors respectively.

[0080] The training set is a preprocessed parallel corpus, consisting of multiple groups of sentences with the same meaning but belonging to different language texts; the training set can be preprocessed, including segmenting the sentences in the training set into words and uniformly converting the uppercase and lowercase letters; the monolingual vocabulary lists of the source language and the target language can be established respectively according to the training set, and the monolingual vocabulary lists are extracted from the training set, and the vocabulary lists include all the words of the corresponding language that appear in the training set.

[0081] A first real number matrix and a second real number matrix are established respectively, wherein the row vector of the first real number matrix is ​​a first attribute vector, and the row vector of the second real number matrix is ​​a second attribute vector. In the neural network machine model established in the embodiment of the present invention, all target words in the target language training set are mapped to an attribute vector pair consisting of the first attribute vector and the second attribute vector.

[0082] Figure 3 Schematic diagram of the mapping relationship between target vocabulary and attribute vector pairs in the method for constructing a neural machine translation model provided by an embodiment of the present invention. Figure 3 As shown, the first attribute vector is composed of the first real matrix Similarly, the second attribute vector is represented by the second real matrix Indicates; where |V y | and d represent the number of target words and the dimension (number of columns) of each attribute vector, respectively.

[0083] like Figure 3 As shown, the jth word y j is mapped to a pair of attribute vectors

[0084]

[0085]

[0086]

[0087] Where g(·) is a mapping function, which represents the mapping relationship between attribute vector pairs and target vocabulary; <·> represents attribute vector pairs, f1(·) and f2(·) are index mapping functions, and Respectively represent A (1) The first attribute vector of the mth row in A (2) The second attribute vector of the nth row in ;

[0088] The domains of the two index mapping functions f1(·) and f2(·) are the same, both are target vocabulary; but their ranges are different, f1(·) maps to the first attribute vector, and f2(·) maps to the second attribute vector.

[0089] Before model training, the target words in the training set are mapped to a pair of initial first attribute vectors and second attribute vectors respectively. At this time, the mapping relationship between the target words and the attribute vector pairs is random. As described in the above embodiment, as the model training continues, the mapping relationship between the target words and the attribute vector pairs will be gradually optimized.

[0090] On the basis of the above embodiments, the embodiments of the present invention lay the foundation for the training of the neural machine translation model by establishing a first real number matrix containing a first attribute vector and a second real number matrix containing a second attribute vector before training, and performing an initial mapping of the target vocabulary to the corresponding attribute vector pairs.

[0091] Further, based on the above embodiment, the preset feature is the score of each pair of attribute vectors corresponding to the target vocabulary in the training set, and the specific calculation formula is as follows:

[0092]

[0093]

[0094] in, is the score of the attribute vector pair consisting of the first attribute vector in the mth row of the first real number matrix and the second attribute vector in the nth row of the second real number matrix corresponding to the j1th target word; They represent the values ​​corresponding to the j1, j2, ..., j r target vocabulary, the logarithm of the probability of the first attribute vector in the mth row of the first real number matrix; They represent the values ​​corresponding to the j1, j2, ..., j r target vocabulary, the logarithm of the probability of the second attribute vector in the nth row of the second real number matrix; wherein the j1th, j2th, ..., jth r The target words are all the same target words in the training set.

[0095] The preset feature is the score of each pair of attribute vectors corresponding to the target vocabulary in the training set. The score of the target vocabulary in the training set corresponding to the corresponding attribute vector pair includes not only the score of the target vocabulary itself corresponding to the corresponding attribute vector pair, but also the score of the same target vocabulary in the training set corresponding to this attribute vector pair. The scores are summed up to obtain the score of each pair of attribute vectors corresponding to the target vocabulary in the training set.

[0096] This method is used to collect preset features because when remapping the target vocabulary and attribute vector pairs, the same target vocabulary can be mapped to the same attribute vector pair. Therefore, the above score calculation also uses the summation method of the same target vocabulary and the corresponding attribute vector pair, which can better achieve the remapping of the attribute vector pair of the same target vocabulary.

[0097] On the basis of the above-mentioned embodiments, the embodiments of the present invention collect the scores of each pair of attribute vectors corresponding to the target vocabulary in the training set as preset features, which is conducive to achieving more reasonable remapping and further facilitating the optimization of the neural machine translation model.

[0098] Further, based on the above embodiment, the target vocabulary and attribute vector pairs are remapped according to the collected preset features, specifically including: arranging all target vocabulary in the training set in descending order according to word frequency; according to the order of word frequency, according to the scores of all attribute vector pairs to be selected corresponding to the current target vocabulary, selecting a pair of attribute vector pairs with the largest score to assign to the current target vocabulary; wherein the attribute vector pair to be selected refers to the attribute vector pair after eliminating the attribute vector pairs selected for the target vocabulary with a higher word frequency than the current target vocabulary.

[0099] According to the word frequency in the training set (the number of times a word appears in the training set), all the target words in the training set are sorted in descending order according to the word frequency, that is, they are sorted in descending order from high to low word frequency. After sorting in descending order, the remapping relationship between each target word and attribute vector pair is determined in turn according to the order of word frequency. The remapping relationship between the target words with high word frequency and the attribute vector pair is determined first, and then the remapping relationship between the target words with low word frequency and the attribute vector pair is determined.

[0100] When determining the remapping relationship between the current target vocabulary and the attribute vector pair, according to the scores of all the attribute vector pairs to be selected corresponding to the current target vocabulary, a pair of attribute vector pairs with the largest score is selected and assigned to the current target vocabulary. The attribute vector pair to be selected refers to the attribute vector pair after eliminating the attribute vector pairs selected by the target vocabulary with a higher word frequency than the current target vocabulary.

[0101] For example, the target vocabulary with the highest frequency has the highest priority and is remapped to the attribute vector pair first. At this time, based on the score of the attribute vector pair corresponding to the target vocabulary with the highest frequency, a pair of attribute vector pairs with the highest score is selected and assigned to the target vocabulary with the highest frequency. When the subsequent target vocabulary is remapped to the attribute vector pair, the attribute vector pair selected by the target vocabulary with a higher frequency than this target vocabulary cannot be selected. The only option is to select the attribute vector pair with the highest score corresponding to the current target vocabulary from the remaining attribute vector pairs and assign it to the current target vocabulary.

[0102] Thus, the remapping of all target vocabulary and attribute vector pairs in the training set is completed.

[0103] Because similar target words have similar context information, similar target words will have similar probability distributions for the first attribute vector and the second attribute vector when predicting during the training process, so similar target words will have similar scores for the same first attribute vector and the same second attribute vector. Although different target words cannot be represented by the same attribute vector pair, the remapping process of the embodiment of the present invention can achieve similar target words being represented by the same first attribute vector or the same second attribute vector, thereby enhancing the expressive power of the neural machine translation model and better achieving translation.

[0104] That is, although two target words cannot be represented by the same attribute vector pair, they can be represented by the same attribute vector. Figure 3 In the example, beijing and china share an attribute vector, and beijing and paris also share an attribute vector.

[0105] The mapping relationship is not matched at the beginning. At the beginning, different attribute variables are randomly assigned to the target vocabulary, that is, beijing and china will not share the same attribute variable. During the training process, the score of each vocabulary for each attribute vector pair is collected, and the target vocabulary and attribute vector pairs are remapped. After multiple iterations, beijing and china can automatically learn to share the same attribute variable.

[0106] If the traditional method adopts the hierarchical method, some prior knowledge needs to be provided, such as beijing and china are similar words. The construction of the neural machine model provided by the embodiment of the present invention does not require such prior knowledge, and the model can automatically cluster similar words during training. As a result, similar words, especially similar low-frequency words and high-frequency words, can be represented by the same attribute vector, which enhances the representation ability of low-frequency words and increases the prediction probability of low-frequency words. Therefore, the translation quality of low-frequency words can be greatly improved while ensuring the translation quality of low-frequency words.

[0107] Traditional machine translation cannot translate low-frequency words. For example, among 1 million target words, only 30,000 to 80,000 target words with the highest frequency can be selected for training and translation. The method provided in the embodiment of the present invention can train and translate all 1 million target words.

[0108] On the basis of the above-mentioned embodiments, the embodiments of the present invention remap the target vocabulary and attribute vector pairs in order according to the frequency of the words, which is beneficial to ensuring the correctness of the mapping relationship of the target vocabulary with high frequency, thereby helping to improve the reliability of the neural machine translation model; and, the embodiments of the present invention do not require the additional prior knowledge required by the traditional method, and similar low-frequency words and high-frequency words in the target vocabulary can be automatically assigned the same attribute vector during training, thereby greatly improving the translation quality of low-frequency words while ensuring the translation quality of high-frequency words.

[0109] Figure 4 is a flow chart of the neural machine translation method provided by an embodiment of the present invention. Figure 4 As shown, the method includes:

[0110] Step 201: Based on the neural machine translation model constructed in the above embodiments, the source sentence is translated into a target sentence.

[0111] The neural machine translation method provided by the embodiment of the present invention can use an attribute-based beam search method for translation.

[0112] Specifically, in the embodiment of the present invention, using the attribute-based beam search method for translation means that, in the order of the target words, the first attribute vectors and the second attribute vectors with the largest probability corresponding to the corresponding target words are retained in sequence, and the product of the probability of all target words corresponding to each first attribute vector and the probability of each second attribute vector is calculated under the constraint relationship of the attribute vectors corresponding to the adjacent target words, and the first attribute vector and the second attribute vector corresponding to each target word when the product is the largest are taken as the first attribute vector and the second attribute vector corresponding to each target word finally determined. After determining the first attribute vector and the second attribute vector corresponding to each target word, according to the above mapping function g -1 Map each pair of attribute vectors to the corresponding target vocabulary.

[0113] The embodiment of the present invention uses an attribute-based beam search method in the decoding stage, which reduces the search space of the target vocabulary, reduces the computational complexity of the model, speeds up the decoding speed, improves the translation efficiency, and enables the machine translation system to quickly respond to translation requests from multiple users; uses a pair of attribute vectors to represent the target vocabulary, greatly reduces the number of parameters used to represent the target vocabulary, effectively solves the problem of out-of-set words in neural machine translation, and greatly improves the translation quality and translation efficiency; at the same time, reduces the overall space overhead of the model, facilitates the deployment and application of the model, and is particularly suitable for the construction and use of offline translation systems for mobile terminals.

[0114] Figure 5 Schematic diagram of the structure of the device for constructing the neural machine translation model provided by the embodiment of the present invention. Figure 5 As shown, the construction device of the neural machine translation model includes a neural machine translation model construction module 10, which is used to construct a neural machine translation model based on an encoder-decoder framework, and the neural machine translation model includes an encoder and a decoder; wherein, when the decoder generates a target vocabulary, it sequentially generates a first attribute vector and a second attribute vector corresponding to the target vocabulary, and then the first attribute vector and the second attribute vector form an attribute vector pair mapped to the corresponding target vocabulary.

[0115] The neural machine translation model construction module 10 constructs a neural machine translation model based on an encoder-decoder framework, wherein the neural machine translation model includes an encoder and a decoder; the decoder in the constructed neural machine translation model adopts a hierarchical decoding method to decode and generate a target vocabulary, wherein the hierarchical decoding method means that when the decoder generates a target vocabulary, it sequentially generates two attribute vectors (two layers) corresponding to the target vocabulary, namely a first attribute vector and a second attribute vector, and then these two attribute vectors form an attribute pair mapped to the corresponding target vocabulary.

[0116] Further, based on the above embodiment, the decoder of the neural machine translation model constructed by the neural machine translation model construction module 10 generates a first attribute vector and a second attribute vector corresponding to the target vocabulary in sequence when generating a target vocabulary, specifically including: obtaining the first attribute hidden state of the current target vocabulary through the hidden state sequence of the source sentence, the context vector corresponding to the current target vocabulary, the second attribute hidden state and the second attribute vector of the previous target vocabulary of the current target vocabulary; obtaining the second attribute hidden state of the current target vocabulary through the context vector corresponding to the current target vocabulary, the first attribute hidden state of the current target vocabulary and the first attribute vector; calculating the probability of the current target vocabulary corresponding to each first attribute vector based on the first attribute hidden state of the current target vocabulary; calculating the probability of the current target vocabulary corresponding to each second attribute vector based on the second attribute hidden state of the current target vocabulary; determining the first attribute vector and the second attribute vector of each target vocabulary according to the order of the target vocabulary and the calculated probabilities of all target vocabulary corresponding to each first attribute vector and the corresponding probabilities of each second attribute vector.

[0117] According to the order of the target words, the probability of each first attribute vector and the probability of each second attribute vector corresponding to all the target words can be calculated. Under the constraint relationship of the attribute vectors corresponding to adjacent target words, the product of the probability of the first attribute vector and the probability of the second attribute vector corresponding to all the target words can be calculated, and the first attribute vector and the second attribute vector corresponding to each target word when the product is the largest are taken as the first attribute vector and the second attribute vector corresponding to each target word finally determined.

[0118] Further, based on the above embodiment, the decoder of the neural machine translation model constructed by the neural machine translation model construction module 10 is used to calculate the probability of the current target vocabulary corresponding to each first attribute vector based on the first attribute hidden state of the current target vocabulary, which is implemented by the following formula:

[0119]

[0120]

[0121] in, represents the probability of the first attribute vector of the mth row in the first real number matrix corresponding to the jth target word; represents the first attribute vector of the mth row in the first real number matrix; It is an intermediate variable in the calculation process; represents the first attribute vector of the i-th row in the first real number matrix; W (1) is a model training parameter for training the first attribute vector, and M is the number of rows of the first real number matrix; is the first attribute hidden state of the jth target word; is the second attribute vector of the j-1th target word; c j is the context vector of the jth target word;

[0122] The probability of the current target word corresponding to each second attribute vector is calculated based on the second attribute hidden state of the current target word, which is achieved through the following formula:

[0123]

[0124]

[0125] in, represents the probability of the second attribute vector of the nth row in the second real number matrix corresponding to the jth target word; represents the second attribute vector of the nth row in the second real number matrix; It is an intermediate variable in the calculation process; W represents the second attribute vector of the lth row in the second real number matrix; (2) is a model training parameter for training the second attribute vector, and N is the number of rows of the second real number matrix; is the second attribute hidden state of the j-th target word; is the first attribute vector of the jth target word; c j is the context vector of the j-th target word.

[0126] Further, based on the above embodiment, the decoder of the neural machine translation model constructed by the neural machine translation model construction module 10 is used to determine the first attribute vector and the second attribute vector of each target vocabulary in the order of the target vocabulary according to the calculated probabilities of all target vocabulary corresponding to each first attribute vector and the corresponding probabilities of each second attribute vector. It is specifically used to: store a preset number of first attribute vectors and second attribute vectors corresponding to each target vocabulary according to the level of probability; calculate the product of the probability of all target vocabulary corresponding to each first attribute vector and the corresponding probability of each second attribute vector under the constraint relationship of the attribute vectors corresponding to adjacent target vocabulary, and take the first attribute vector and the second attribute vector corresponding to each target vocabulary when the product is the largest as the first attribute vector and the second attribute vector corresponding to each target vocabulary finally determined.

[0127] On the basis of the above-mentioned embodiment, the embodiment of the present invention can further reduce the computational complexity and improve the system operation efficiency by only storing a preset number of first attribute vectors and second attribute vectors corresponding to each target vocabulary.

[0128] Further, based on the above embodiment, the construction device of the neural machine translation model also includes a training module for training the neural machine translation model, specifically for: collecting preset features during the training of the neural machine translation model, and pausing training when the model converges; remapping the target vocabulary and attribute vector pairs in the training set according to the collected preset features; continuing to train the neural machine translation model using the remapped attribute vector pairs; repeating the above steps until the training is terminated when the preset training time or number of training times is reached.

[0129] The convergence of the neural machine translation model is judged by the fact that the cross entropy on the validation set no longer decreases after multiple model iterations. Pausing training means keeping all model parameters unchanged after a complete round of training. When retraining, the model parameters after the training is paused are used, and the model is continued to be trained using the remapped attribute vector pairs.

[0130] Repeat the above steps, that is, repeatedly execute "collecting preset features during the training of the neural machine translation model, and pausing the training when the model converges; remapping the target vocabulary and attribute vector pairs in the training set according to the collected preset features; and continuing to train the neural machine translation model using the remapped attribute vector pairs", until the training is terminated when the preset training time or number of training times is reached.

[0131] On the basis of the above-mentioned embodiments, the embodiments of the present invention remap the target vocabulary and attribute vector pairs according to the collected preset features when the training is paused, and continue to train the neural machine translation model according to the remapped attribute vector pairs, so as to gradually optimize the mapping relationship between the target vocabulary and attribute vector pairs through learning, which is conducive to obtaining a more optimized neural machine translation model.

[0132] Further, based on the above embodiment, the construction device of the neural machine translation model also includes a first real number matrix establishment module, a second real number matrix establishment module and an initial mapping module, wherein: the first real number matrix establishment module is used to establish a first real number matrix, the first real number matrix includes a first attribute vector; the second real number matrix establishment module is used to establish a second real number matrix, the second real number matrix includes a second attribute vector; the initial mapping module is used to map the target vocabulary in the training set to a pair of initial first attribute vectors and second attribute vectors respectively.

[0133] In the neural network machine model established by the embodiment of the present invention, all target words in the target language training set are mapped to an attribute vector pair consisting of a first attribute vector and a second attribute vector.

[0134] Before model training, the target words in the training set are mapped to a pair of initial first attribute vectors and second attribute vectors respectively. At this time, the mapping relationship between the target words and the attribute vector pairs is random. As described in the above embodiment, as the model training continues, the mapping relationship between the target words and the attribute vector pairs will be gradually optimized.

[0135] On the basis of the above embodiments, the embodiments of the present invention lay the foundation for the training of the neural machine translation model by establishing a first real number matrix containing a first attribute vector and a second real number matrix containing a second attribute vector before training, and performing an initial mapping of the target vocabulary to the corresponding attribute vector pairs.

[0136] Further, based on the above embodiment, the preset feature is the score of each pair of attribute vectors corresponding to the target vocabulary in the training set, and the specific calculation formula is as follows:

[0137]

[0138] in, is the score of the attribute vector pair consisting of the first attribute vector in the mth row of the first real number matrix and the second attribute vector in the nth row of the second real number matrix corresponding to the j1th target word; They represent the values ​​corresponding to the j1, j2, ..., j r target vocabulary, the logarithm of the probability of the first attribute vector in the mth row of the first real number matrix; They represent the values ​​corresponding to the j1, j2, ..., j r target vocabulary, the logarithm of the probability of the second attribute vector in the nth row of the second real number matrix; wherein the j1th, j2th, ..., jth r The target words are all the same target words in the training set.

[0139] On the basis of the above-mentioned embodiments, the embodiments of the present invention collect the scores of each pair of attribute vectors corresponding to the target vocabulary in the training set as preset features, which is conducive to achieving more reasonable remapping and further facilitating the optimization of the neural machine translation model.

[0140] Further, based on the above embodiment, when the training module is used to remap the target vocabulary and attribute vector pairs according to the collected preset features, it is specifically used to: arrange all target vocabulary in the training set in descending order according to the word frequency; according to the order of word frequency, according to the scores of all attribute vector pairs to be selected corresponding to the current target vocabulary, select a pair of attribute vector pairs with the largest score and assign them to the current target vocabulary; wherein the attribute vector pair to be selected refers to the attribute vector pair after eliminating the attribute vector pairs selected for the target vocabulary with a higher word frequency than the current target vocabulary.

[0141] Arrange in descending order from high to low word frequency. After descending order, determine the remapping relationship between each target word and attribute vector pair in order of word frequency, first determine the remapping relationship between target words and attribute vector pairs with high word frequency, and then determine the remapping relationship between target words and attribute vector pairs with low word frequency.

[0142] The remapping process of the embodiment of the present invention can achieve similar target vocabulary represented by the same first attribute vector or the same second attribute vector, thereby enhancing the expression ability of the neural machine translation model and better achieving translation.

[0143] On the basis of the above-mentioned embodiments, the embodiments of the present invention remap the target vocabulary and attribute vector pairs in order according to the frequency of the words, which is beneficial to ensuring the correctness of the mapping relationship of the target vocabulary with high frequency, thereby helping to improve the reliability of the neural machine translation model; and, the embodiments of the present invention do not require the additional prior knowledge required by the traditional method, and similar low-frequency words and high-frequency words in the target vocabulary can be automatically assigned the same attribute vector during training, thereby greatly improving the translation quality of low-frequency words while ensuring the translation quality of high-frequency words.

[0144] Figure 6 Schematic diagram of the structure of the neural machine translation device provided by the embodiment of the present invention. Figure 6 As shown, the neural machine translation device includes a translation module 20, which is specifically used to translate a source sentence into a target sentence based on the neural machine translation model constructed in the above embodiments.

[0145] The embodiment of the present invention uses an attribute-based beam search method in the decoding stage, which reduces the search space of the target vocabulary, reduces the computational complexity of the model, speeds up the decoding speed, improves the translation efficiency, and enables the machine translation system to quickly respond to translation requests from multiple users; uses a pair of attribute vectors to represent the target vocabulary, greatly reduces the number of parameters used to represent the target vocabulary, effectively solves the problem of out-of-set words in neural machine translation, and greatly improves the translation quality and translation efficiency; at the same time, reduces the overall space overhead of the model, facilitates the deployment and application of the model, and is particularly suitable for the construction and use of offline translation systems for mobile terminals.

[0146] The device provided in the embodiment of the present invention is used for the above method. The specific functions can refer to the above method flow and will not be repeated here.

[0147] Figure 7 Schematic diagram of the physical structure of the electronic device provided by the embodiment of the present invention. Figure 7 As shown, the electronic device may include: a processor 710, a communication interface 720, a memory 730 and a communication bus 740, wherein the processor 710, the communication interface 720 and the memory 730 communicate with each other through the communication bus 740. The processor 710 may call the logic instructions in the memory 730 to execute the following method: construct a neural machine translation model based on an encoder-decoder framework, wherein the neural machine translation model includes an encoder and a decoder; wherein when the decoder generates a target vocabulary, it sequentially generates a first attribute vector and a second attribute vector corresponding to the target vocabulary, and then the first attribute vector and the second attribute vector form an attribute vector pair mapped to the corresponding target vocabulary.

[0148] In addition, the logic instructions in the above-mentioned memory 730 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on such an understanding, the technical solution of the present invention, in essence, 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, and the computer software product is stored in a storage medium, including a number of instructions for 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: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program codes.

[0149] Through the description of the above implementation modes, those skilled in the art can clearly understand that each implementation mode can be implemented by means of software plus a necessary general hardware platform, and of course can also be implemented by hardware.

[0150] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.

[0151] 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 embodiments of the present invention.< / eos> < / eos> < / eos>

Claims

1. A method for constructing a neural machine translation model, characterized in that: include: Building a neural machine translation model based on an encoder-decoder framework, wherein the neural machine translation model includes an encoder and a decoder; Wherein, when generating the target vocabulary, the decoder sequentially generates a first attribute vector and a second attribute vector corresponding to the target vocabulary, and then the first attribute vector and the second attribute vector form an attribute vector pair mapped to the corresponding target vocabulary; when generating the target vocabulary, the decoder sequentially generates a first attribute vector and a second attribute vector corresponding to the target vocabulary, specifically including: Obtaining the first attribute hidden state of the current target vocabulary through the hidden state sequence of the source sentence, the context vector corresponding to the current target vocabulary, the second attribute hidden state of the previous target vocabulary of the current target vocabulary, and the second attribute vector; Obtaining a second attribute hidden state of the current target vocabulary through a context vector corresponding to the current target vocabulary, a first attribute hidden state of the current target vocabulary, and the first attribute vector; Calculate the probability of the current target vocabulary corresponding to each first attribute vector based on the first attribute hidden state of the current target vocabulary; Calculate the probability of the current target word corresponding to each second attribute vector based on the second attribute hidden state of the current target word; According to the order of the target words, the first attribute vector and the second attribute vector of each target word are determined according to the calculated probabilities of all the target words corresponding to each first attribute vector and the probabilities of all the target words corresponding to each second attribute vector.

2. The method according to claim 1, characterized in that The calculation of the probability of the current target vocabulary corresponding to each first attribute vector based on the first attribute hidden state of the current target vocabulary is implemented by the following formula: in, represents the probability of the first attribute vector of the mth row in the first real number matrix corresponding to the jth target word; represents the first attribute vector of the mth row in the first real number matrix; It is an intermediate variable in the calculation process; represents the first attribute vector of the i-th row in the first real number matrix; W (1) is a model training parameter for training the first attribute vector, and M is the number of rows of the first real number matrix; is the first attribute hidden state of the jth target word; is the second attribute vector of the j-1th target word; c j is the context vector of the jth target word; The calculation of the probability of the current target vocabulary corresponding to each second attribute vector based on the second attribute hidden state of the current target vocabulary is implemented by the following formula: in, represents the probability of the second attribute vector of the nth row in the second real number matrix corresponding to the jth target word; represents the second attribute vector of the nth row in the second real number matrix; It is an intermediate variable in the calculation process; W represents the second attribute vector of the lth row in the second real number matrix; (2) is a model training parameter for training the second attribute vector, and N is the number of rows of the second real number matrix; is the second attribute hidden state of the j-th target word; is the first attribute vector of the jth target word; c j is the context vector of the j-th target word.

3. The method according to claim 1, characterized in that The method of determining the first attribute vector and the second attribute vector of each target word according to the calculated probabilities of all target words corresponding to each first attribute vector and the calculated probabilities of all target words corresponding to each second attribute vector in the order of the target words specifically includes: According to the probability, a preset number of first attribute vectors and second attribute vectors corresponding to each target word are stored; Under the constraint relationship of the attribute vectors corresponding to adjacent target words, the product of the probability of all target words corresponding to each first attribute vector and the probability of each second attribute vector is calculated, and the first attribute vector and the second attribute vector corresponding to each target word when the product is the largest are taken as the first attribute vector and the second attribute vector corresponding to each target word finally determined.

4. The method according to claim 1, characterized in that: The method further includes training a neural machine translation model, wherein the training of the neural machine translation model specifically includes: Collecting preset features during training of the neural machine translation model and pausing training when the model converges; Remapping the target vocabulary and attribute vector pairs in the training set according to the collected preset features; Continue training the neural machine translation model using the remapped attribute vector pairs; Repeat the above steps until the preset training time or training times are reached and then terminate the training.

5. The method according to claim 4, characterized in that Before training the neural machine translation model, the method further includes: Establishing a first real number matrix and a second real number matrix respectively, wherein the first real number matrix includes a first attribute vector, and the second real number matrix includes a second attribute vector; The target vocabulary in the training set is mapped to a pair of initial first attribute vectors and second attribute vectors respectively.

6. The method according to claim 5, characterized in that The preset feature is the score of each pair of attribute vectors corresponding to the target vocabulary in the training set, and the specific calculation formula is as follows: in, is the score of the attribute vector pair consisting of the first attribute vector in the mth row of the first real number matrix and the second attribute vector in the nth row of the second real number matrix corresponding to the j1th target word; ……、 They represent the values ​​corresponding to the j1, j2, ..., j r target vocabulary, the logarithm of the probability of the first attribute vector in the mth row of the first real number matrix; ……、 They represent the values ​​corresponding to the j1, j2, ..., j r target vocabulary, the logarithm of the probability of the second attribute vector in the nth row of the second real number matrix; wherein the j1th, j2th, ..., jth r The target words are all the same target words in the training set.

7. The method according to claim 6, characterized in that The remapping of the target vocabulary and attribute vector pair according to the collected preset features specifically includes: Arrange all target words in the training set in descending order according to their frequency; According to the order of word frequency, based on the scores of all attribute vector pairs to be selected corresponding to the current target word, select a pair of attribute vector pairs with the largest score and assign it to the current target word; The attribute vector pairs to be selected refer to the attribute vector pairs after eliminating the attribute vector pairs selected for the target vocabulary with a higher word frequency than the current target vocabulary.

8. A neural machine translation method, characterized in that: include: Based on the neural machine translation model constructed by any one of the methods of claims 1 to 7, the source sentence is translated into the target sentence.

9. A device for constructing a neural machine translation model, characterized in that: include: A neural machine translation model building module, used to build a neural machine translation model based on an encoder-decoder framework, wherein the neural machine translation model includes an encoder and a decoder; Wherein, when generating the target vocabulary, the decoder sequentially generates a first attribute vector and a second attribute vector corresponding to the target vocabulary, and then forms an attribute vector pair composed of the first attribute vector and the second attribute vector and maps it to the corresponding target vocabulary; When generating a target vocabulary, the decoder sequentially generates a first attribute vector and a second attribute vector corresponding to the target vocabulary, specifically including: obtaining the first attribute hidden state of the current target vocabulary through a hidden state sequence of a source sentence, a context vector corresponding to the current target vocabulary, and the second attribute hidden state and the second attribute vector of the previous target vocabulary of the current target vocabulary; obtaining the second attribute hidden state of the current target vocabulary through the context vector corresponding to the current target vocabulary, the first attribute hidden state of the current target vocabulary and the first attribute vector; calculating the probability that the current target vocabulary corresponds to each first attribute vector based on the first attribute hidden state of the current target vocabulary; calculating the probability that the current target vocabulary corresponds to each second attribute vector based on the second attribute hidden state of the current target vocabulary; and determining the first attribute vector and the second attribute vector of each target vocabulary according to the calculated probabilities of all target vocabulary corresponding to each first attribute vector and the corresponding probabilities of each second attribute vector in the order of the target vocabulary.

10. A neural machine translation device, characterized in that: include: A translation module, used to translate a source sentence into a target sentence based on a neural machine translation model constructed by any method of claims 1 to 7.

11. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the program, the steps of the method according to any one of claims 1 to 7 are implemented.

12. 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 steps of the method according to any one of claims 1 to 7 are implemented.

Citation Information

Patent Citations

  • Method of translation, method for determining target information and related devices

    CN107368476A

  • Hierarchical structure-based neural-network machine translation model

    CN107423290A

  • Neural machine translation method and device based on word vector connection technology

    CN107729329A

  • Translation model-based training and translation methods and apparatuses, and storage medium

    CN108304390A

  • Decoding method based on deep neural network translation model

    CN108647214A