Text translation method and device, computer equipment and storage medium
By segmenting and encoding the text to be translated, and combining it with a domain-specific vocabulary database, the translation vocabulary is predicted and determined, thus solving the problem of inaccurate vocabulary translation in professional fields and improving translation accuracy.
Patent Information
- Application Number
- CN202311524855.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-11-15
- Publication Date
- 2026-01-27
AI Technical Summary
Current machine translation technology lacks language data in specialized fields, resulting in low accuracy in vocabulary translation.
By segmenting the text to be translated, obtaining the segmentation object encoding vector, predicting the translation words, and using a pre-set domain vocabulary database to determine the translation words, the translated text is output.
It improves the accuracy of translation of professional terminology and avoids inaccurate translations caused by the scarcity of terminology in that field.
Smart Images

Figure CN121413638A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of natural language processing technology, and in particular to a text translation method, apparatus, computer device, and storage medium. Background Technology
[0002] Machine translation (MT) is a technology that uses computers to translate text from natural language into text in a target natural language. It is one of the core tasks of natural language processing and is of great value for applications such as cross-language communication. With the widespread application of deep neural networks in natural language processing, neural network-based machine translation has become the mainstream method in the field.
[0003] In related technologies, when translating between multiple natural languages, machine translation models need to be trained separately using corpora of the various natural languages before being applied.
[0004] Current large-scale parallel corpora mainly consist of general data such as news and policy documents, lacking language data from specialized fields (such as architecture, electronics, and computers), resulting in low accuracy in vocabulary translation. Summary of the Invention
[0005] This application proposes a text translation method, apparatus, computer equipment, and storage medium to improve the accuracy of vocabulary translation.
[0006] Firstly, a text translation method is provided, including:
[0007] Obtain the text to be translated, and segment the text to be translated to obtain multiple segmentation objects corresponding to the text to be translated;
[0008] Each segmented object is encoded to obtain a segmented object encoding vector for each segmented object;
[0009] Predict the translation vocabulary for the encoding vector of each segmented object to obtain the translation vocabulary prediction result for each segmented object;
[0010] Based on the translation vocabulary prediction results and the preset domain vocabulary database, the domain vocabulary in the translation vocabulary prediction results is determined;
[0011] Based on the translation vocabulary prediction results and the domain vocabulary, the translated text of the text to be translated is output.
[0012] Secondly, a text translation device is provided, comprising:
[0013] The acquisition module is used to acquire the text to be translated and segment the text to be translated to obtain multiple segmentation objects corresponding to the text to be translated;
[0014] The encoding module is used to encode each of the segmented objects to obtain a segmentation object encoding vector for each of the segmented objects;
[0015] The prediction module is used to predict the translation vocabulary of the encoding vector of each segmented object, and obtain the translation vocabulary prediction result of each segmented object;
[0016] The determination module is used to determine the domain words in the translation word prediction results based on the translation word prediction results and a preset domain word database;
[0017] The output module is used to output the translated text of the text to be translated based on the translation vocabulary prediction results and the domain vocabulary.
[0018] Optionally, in some embodiments of this application, the prediction module includes:
[0019] The annotation submodule is used to label each segmented object to obtain the label of each segmented object;
[0020] The first encoding submodule is used to encode each of the tags to obtain a tag encoding vector corresponding to each tag;
[0021] A submodule is obtained to obtain the fusion vector information of each segmented object based on the encoding vector of each segmented object and the encoding vector of each label;
[0022] The second encoding submodule is used to encode each of the fused vector information to obtain word vector representation information;
[0023] The prediction submodule is used to predict the translation vocabulary for each of the word vector representation information, and obtain the translation vocabulary prediction result for each segmentation object.
[0024] Optionally, in some embodiments of this application, the first encoding submodule includes:
[0025] The acquisition unit is used to acquire a preset dimension encoding vector corresponding to each of the labels;
[0026] The encoding unit is used to encode the label using the preset dimension encoding vector to obtain the label encoding vector corresponding to the label.
[0027] Optionally, in some embodiments of this application, the obtained submodule includes:
[0028] A transformation unit is used to perform a linear transformation on the tag encoding vector to obtain the hidden layer vector corresponding to the tag encoding vector;
[0029] A computing unit is used to calculate the cross-attention information between the hidden layer vector and the segmentation object encoding vector;
[0030] The weighting unit is used to weight the cross-attention information and the segmentation object encoding vector to obtain the fusion vector information.
[0031] Optionally, in some embodiments of this application, the prediction submodule includes:
[0032] An update unit is used to update the state of each word vector representation information to obtain each updated word vector representation information.
[0033] The first prediction unit is used to predict the translation vocabulary for each of the updated word vector representation information, and obtain the translation vocabulary prediction result for each segmented object.
[0034] Optionally, in some embodiments of this application, the prediction submodule includes:
[0035] The decoding unit is used to decode each word vector representation information to obtain the decoded representation vector of each segmented object;
[0036] The second prediction unit is used to predict the translation vocabulary of each of the decoded representation vectors, and obtain the translation vocabulary prediction result of each segmentation object.
[0037] Optionally, in some embodiments of this application, the determining module includes:
[0038] An extraction submodule is used to extract a preset number of target translation words and the predicted probability of the target translation words from the translation word prediction results;
[0039] The matching submodule is used to match each of the target translation terms with each term to be matched in the domain term database;
[0040] The update submodule is used to update the translation word prediction result based on the preset enhancement coefficient and the word to be matched if there is a match between the word to be matched and the target translation word.
[0041] The selection submodule is used to select the target translation word with the highest predicted probability from the translation word prediction results as the domain word.
[0042] Thirdly, a computer device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the steps of the above-described text translation method.
[0043] Fourthly, a computer-readable storage medium is provided, the computer-readable storage medium storing a computer program, which, when executed by a processor, implements the steps of the above-described text translation method.
[0044] This application provides a text translation method, apparatus, computer device, and storage medium. The method involves acquiring the text to be translated and segmenting it to obtain multiple segmentation objects. Each segmentation object is then encoded to obtain a segmentation object encoding vector. The translation vocabulary for each segmentation object's encoding vector is predicted, resulting in a translation vocabulary prediction result for each segmentation object. Based on the translation vocabulary prediction result and a pre-set domain vocabulary database, domain vocabulary is determined from the translation vocabulary prediction result. Finally, based on the translation vocabulary prediction result and the domain vocabulary, the translated text of the text to be translated is output. In the text translation scheme provided in this application, by predicting the translation vocabulary prediction results for multiple segmentation objects of the text to be translated, and then determining the domain vocabulary from the translation vocabulary prediction results, the translated text of the text to be translated is output based on each translation vocabulary prediction result and the domain vocabulary. Therefore, outputting the translated text of the text to be translated based on the translation vocabulary prediction result for each segmentation object and the domain vocabulary within the translation vocabulary prediction result can avoid the problem of inaccurate translation caused by the scarcity of domain vocabulary in professional fields when using machine translation, thus improving the accuracy of vocabulary translation. Attached Figure Description
[0045] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0046] Figure 1 An application environment diagram for the text translation method provided in the embodiments of this application;
[0047] Figure 2 A flowchart of the text translation method provided in the embodiments of this application;
[0048] Figure 3 A flowchart illustrating the process of determining the predicted translation terms for embodiments of this application;
[0049] Figure 4A structural block diagram of the text translation device provided in the embodiments of this application;
[0050] Figure 5 This is a structural block diagram of a computer device provided in an embodiment of this application. Detailed Implementation
[0051] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0052] Furthermore, the described features, structures, or characteristics can be combined in any suitable manner in one or more embodiments. Numerous specific details are provided in the following description to give a thorough understanding of embodiments of this application. However, those skilled in the art will recognize that the technical solutions of this application can be practiced without one or more of the specific details, or other methods, components, apparatuses, steps, etc., can be employed. In other instances, well-known methods, apparatuses, implementations, or operations are not shown or described in detail to avoid obscuring various aspects of this application.
[0053] The block diagrams shown in the accompanying drawings are merely functional entities and do not necessarily correspond to physically independent entities. That is, these functional entities can be implemented in software, in one or more hardware modules or integrated circuits, or in different network and / or processor devices and / or microcontroller devices.
[0054] The flowcharts shown in the accompanying drawings are merely illustrative and do not necessarily include all content and operations / steps, nor do they necessarily have to be performed in the described order. For example, some operations / steps can be broken down, while others can be combined or partially combined; therefore, the actual execution order may change depending on the specific circumstances.
[0055] The text translation method provided in this invention can be applied to, for example... Figure 1In this application environment, the target terminal 110 communicates with the user 120 via network 130, and the user can operate the target terminal 110. The computer device 110 can acquire the text to be translated and segment it to obtain multiple segmentation objects corresponding to the text to be translated; encode each segmentation object to obtain a segmentation object encoding vector for each segmentation object; predict the translation vocabulary for each segmentation object encoding vector to obtain a translation vocabulary prediction result for each segmentation object; determine the domain vocabulary in the translation vocabulary prediction result based on the translation vocabulary prediction result and a preset domain vocabulary database; output the translated text of the text to be translated based on the translation vocabulary prediction result and the domain vocabulary, and display the translated text of the text to be translated through the target terminal 110. Furthermore, the translated text of the text to be translated can also be fed back to the target terminal 110. In this invention, the translation vocabulary prediction results of multiple segmentation objects of the text to be translated are predicted, and then the domain vocabulary in the translation vocabulary prediction results are determined. Based on each translation vocabulary prediction result and the domain vocabulary, the translated text of the text to be translated is output. As can be seen, by outputting the translated text of the text to be translated based on the translation vocabulary prediction results of each segmented object and the domain vocabulary in the translation vocabulary prediction results, the problem of inaccurate translation caused by the scarcity of domain vocabulary in professional fields when using machine translation can be avoided, which is conducive to improving the accuracy of vocabulary translation. The target terminal 110 can be, but is not limited to, various smartphones 110-1, tablet computers 110-2, and laptop computers 110-3. The invention will now be described in detail through specific embodiments.
[0056] Please see Figure 2 As shown, Figure 2 This is a flowchart illustrating a text translation method provided in an embodiment of the present invention. This method can be applied to both terminals and servers; this embodiment uses server-side application as an example. The text translation method includes the following steps:
[0057] 101: Obtain the text to be translated and segment it to obtain multiple segmentation objects corresponding to the text to be translated.
[0058] Optionally, the text to be translated can be segmented based on a dictionary to obtain multiple segmented objects corresponding to the text to be translated.
[0059] For example, if the dictionary includes words such as "this is", "a", "synchronizer", and "machine", the text to be translated could be "This is a synchronizer". When the text to be translated is segmented based on the dictionary, three segmented objects are obtained: "this is", "a", and "synchronizer".
[0060] 102: Encode each segmentation object to obtain the segmentation object encoding vector for each segmentation object.
[0061] In this process, Natural Language Processing (NPL) tools can be used to encode each segmentation object input, resulting in a segmentation object encoding vector for each segmentation object. The NPL tool can be a word-to-vector (Word2vec) model.
[0062] 103: Predict the translation vocabulary of the encoding vector for each segmented object, and obtain the translation vocabulary prediction results for each segmented object.
[0063] Optionally, a classification model can be used to predict the translation vocabulary of the encoding vector of each segmented object, thereby obtaining the translation vocabulary prediction result for each segmented object.
[0064] In one scenario, the label of each segmentation object can be determined, and then the label encoding vector of each label can be obtained. Based on the segmentation object encoding vector and the label encoding vector of each segmentation object, the fusion vector information of each segmentation object can be obtained. Therefore, based on the fusion vector information, the translation vocabulary prediction result for each segmentation object can be obtained. That is, optionally, in some embodiments, the step "predicting the translation vocabulary of each segmentation object's encoding vector and obtaining the translation vocabulary prediction result for each segmentation object" may further include:
[0065] (11) Label each segmentation object to obtain the label of each segmentation object;
[0066] Each segmented object can be labeled using labels from a pre-defined label dataset to obtain the label for each segmented object. For example, the pre-defined label dataset includes labels "PN", "PER", "LOC", "ORG", and "MASK", where "PN" is a proper noun label, "PER" is a personal name label, "LOC" is a place name label, "ORG" is an organization name label, and "MASK" is a non-entity word label.
[0067] (12) Encode each label to obtain the label encoding vector corresponding to each label;
[0068] (13) Based on the encoding vector of each segmented object and the encoding vector of each label, obtain the fusion vector information of each segmented object;
[0069] (14) Encode each fused vector information to obtain word vector representation information;
[0070] (15) Predict the translation vocabulary of each word vector representation information to obtain the translation vocabulary prediction results for each segmentation object.
[0071] For example, assuming the text to be translated is "grid-based control technology achieves power source characteristics similar to, or even exceeding, those of synchronous machines based on reliable control of energy storage converters," then multiple segmentation objects are "grid-based control technology," "energy storage converter," "reliable," "control," "synchronous machine," "similar," "exceeding," "synchronous machine," "voltage," and "external characteristics." After labeling each segmentation object, the corresponding tags for each segmentation object are obtained, namely, "PN," "MASK," "MASK," "PN," "MASK," "MASK," "PN," "MASK," and "PN," where PN is a proper noun tag and MASK is a non-entity word tag. Next, one-hot encoding is used to encode each tag, obtaining a tag encoding vector for each tag. Then, based on a cross-attention mechanism, the segmentation object encoding vector and the tag encoding vector corresponding to each segmentation object are fused to obtain the fused vector information for each segmentation object. Then, an encoder is used to encode the fused vector information for each segmentation object to obtain the word vector representation information for each segmentation object. Finally, the translation vocabulary for each word vector representation information is predicted to obtain the translation vocabulary prediction result for each segmentation object.
[0072] Each label can be encoded using a preset dimension encoding vector to obtain the label encoding vector corresponding to the label. That is, optionally, in some embodiments, the step "encoding each label to obtain the label encoding vector corresponding to each label" further includes:
[0073] (21) Obtain the preset dimension encoding vector corresponding to each label;
[0074] The dimension of the preset dimension encoding vector can be 4 or 5 dimensions. The specific dimension is set according to the actual application scenario and is not specifically limited here.
[0075] (22) The label is encoded using a preset dimension encoding vector to obtain the label encoding vector corresponding to the label.
[0076] Optionally, assuming the preset label dataset includes the labels “PN”, “PER”, “LOC”, “ORG” and “MASK”, the preset dimension encoding vector corresponding to each label can be [1,0,0,0,0], [0,1,0,0,0], [0,0,1,0,0], [0,0,0,1,0], [0,0,0,1,0] and [0,0,0,0,1].
[0077] Optionally, assuming the preset label dataset includes the labels “PN”, “PER”, “LOC”, “ORG” and “MASK”, the preset dimension encoding vector corresponding to each label can be [1,0,0,0], [0,1,0,0], [0,0,1,0], [0,0,0,1] and [0,0,0,0] respectively.
[0078] A linear transformation can be performed on the label encoding vector to make its dimension consistent with the dimension of the segmentation object encoding vector. Then, the cross-attention information of the linearly transformed label encoding vector and the segmentation object encoding vector is calculated to obtain the fused vector information. That is, optionally, in some embodiments, the step "obtaining the fused vector information of each segmentation object based on each segmentation object encoding vector and each label encoding vector" further includes:
[0079] (31) Perform a linear transformation on the tag encoding vector to obtain the hidden layer vector corresponding to the tag encoding vector;
[0080] The hidden layer vector corresponding to the label encoding vector can be calculated based on the following formula (1):
[0081] H y =Linear(Emb) y (1)
[0082] In the formula, H y The hidden layer vector corresponding to the label encoding vector, Linear(Emb) y The linear transformation layer performs a linear transformation on the tag encoding vector.
[0083] (32) Calculate the cross-attention information between the hidden layer vector and the segmentation object encoding vector;
[0084] Cross-attention information can be calculated based on the following formula (2):
[0085] H x =Multihead(Emb x H y H y (2)
[0086] In the formula, H x For cross-attention information, Emb x H is the encoding vector for segmented objects. y The hidden layer vector corresponds to the label encoding information. Multihead is a multi-head attention mechanism, where Multihead is calculated as follows:
[0087] Multihead(Q,K,V)=Concat(head1,head2,...,head M W,
[0088]
[0089] In the formula, Q is the query vector, K is the key vector, V is the value vector, and head is the head vector. i Let M represent the output of the i-th head, M represent the number of heads, and W be the output transformation matrix. i k W is the parameter transformation matrix corresponding to the key vector of the i-th head. i Q W is the parameter transformation matrix corresponding to the query vector of the i-th head. i v Let be the parameter transformation matrix corresponding to the value vector of the i-th head.
[0090] (33) Weight the cross-attention information and the segmentation object encoding vector to obtain the fused vector information.
[0091] The fusion vector information can be calculated based on the following formula (3):
[0092] H = α * Emb x +(1-α)H x (3)
[0093] In the formula, H represents the fused vector information, and Emb... x H is the encoding vector for segmented objects. x For cross-attention information, α is a hyperparameter. This hyperconstant is a constant value, and its specific value is determined according to the actual application scenario. No specific limit is made here.
[0094] Positional information can be added to the fused vector information to obtain word vector representation information with positional information. This word vector representation information with positional information is then input into a position-forward network (FFN) to update the positional state of the segmentation object's encoding vector, thereby obtaining updated word vector representation information. Based on this updated word vector representation information, the translation vocabulary prediction result for each segmentation object is then obtained. That is, optionally, in some embodiments, the step "predicting the translation vocabulary for each word vector representation information and obtaining the translation vocabulary prediction result for each segmentation object" further includes:
[0095] (41) Update the state of each word vector representation information to obtain each updated word vector representation information;
[0096] The updated word vector representation information can be calculated according to the following formula (4):
[0097]
[0098] In the formula, H enc H represents the updated word vector representation information, and PE represents the fused vector information. t1 (x) is the positional embedding layer representing the word vector representation information of the text x to be translated. E represents the hidden layer dimension of the model. t2 This represents word vector information with positional embeddings.
[0099] (42) Predict the translation vocabulary of each updated word vector representation information to obtain the translation vocabulary prediction result for each segmentation object.
[0100] The translation vocabulary prediction results include the predicted translation vocabulary of the segmented object and the prediction probability corresponding to each predicted translation vocabulary. For example, the translation vocabulary prediction results of the segmented object include U = (U1, U2, U3, U4, U5) and the prediction probability P = (P1, P2, P3, P4, P5) corresponding to U.
[0101] A pre-trained decoder can be used to decode each updated word vector representation information to obtain a decoded representation vector; then, a pre-trained classification layer is used to predict the translation vocabulary of each decoded representation vector to obtain the translation vocabulary prediction result for each segmented object. The decoder can be composed of a multi-head sub-attention layer, a multi-head cross-attention layer, and a feedforward neural network layer. The updated word vector representation information can be decoded using the following formula (5) to obtain the decoded representation vector:
[0102]
[0103] In the formula, E t2 H represents word vector information with positional embeddings. enc H represents the updated word vector information. t1 For E t2 Cross-attention information obtained from multi-head attention calculation, H c1 For H t1 and H enc Cross-attention information obtained from multi-head attention calculation, H dec1 The decoded representation vector is then used. Next, a pre-trained classification layer can be used to predict the translation vocabulary for each decoded representation vector, yielding the translation vocabulary prediction result for each segmented object. Specifically, the decoded representation vector can be predicted using the following formula (6) to obtain the translation vocabulary prediction result for the segmented object:
[0104] U = softmax(W) P H dec1 +b)(6)
[0105] In the formula, U represents the predicted translation vocabulary, and W... P Here, b is the weight parameter, and H is the offset. dec1 This is the decoded representation vector.
[0106] The word vector representation information can be decoded to obtain the decoded representation vector of each segmented object. Then, classification prediction is performed on each decoded representation vector to obtain the translation vocabulary prediction result for each segmented object. That is, optionally, in some embodiments, the step "predicting the translation vocabulary for each word vector representation information to obtain the translation vocabulary prediction result for each segmented object" further includes:
[0107] (51) Decode the word vector representation information to obtain the decoded representation vector of each segmented object;
[0108] (52) Predict the translation vocabulary for each decoded representation vector to obtain the translation vocabulary prediction results for each segmented object.
[0109] A pre-trained decoder can be used to decode the word vector representation information of each word to obtain the decoded representation vector; then, a pre-trained classification layer is used to predict the translation vocabulary of each decoded representation vector to obtain the translation vocabulary prediction result of each segmented object. The decoder can be composed of a multi-head sub-attention layer, a multi-head cross-attention layer, and a feedforward neural network layer. Among them, the word vector representation vector is mapped based on the feedforward neural network to obtain the mapped word vector representation vector, and the updated word vector representation information can be decoded by the following formula (7) to obtain the decoded representation vector:
[0110]
[0111] In the formula, E t1 E represents information as word vectors enc H represents the information of the mapped word vectors. t2 For E t1 Cross-attention information obtained from multi-head attention calculation, H c2 For H t2 and E enc Cross-attention information obtained from multi-head attention calculation, H dec2 The decoded representation vector is then used. Next, a pre-trained classification layer can be used to predict the translation vocabulary for each decoded representation vector, yielding the translation vocabulary prediction result for each segmented object. Specifically, the decoded representation vector can be predicted using the following formula (8) to obtain the translation vocabulary prediction result for the segmented object:
[0112] U = softmax(W) P H dec2+b)(8)
[0113] In the formula, U represents the predicted translation vocabulary, and W... P Here, b is the weight parameter, and H is the offset. dec2 This is the decoded representation vector.
[0114] 104: Based on the translation vocabulary prediction results and the preset domain vocabulary database, determine the domain vocabulary in the translation vocabulary prediction results.
[0115] The domain vocabulary database can include multiple words to be matched. Optionally, the domain vocabulary database can be obtained by manually filtering and annotating the bilingual corpus after removing common words.
[0116] For example, assuming the predicted translation vocabulary for the segmentation object includes U = (U1, U2, U3, U4, U5) and the predicted probability P = (P1, P2, P3, P4, P5) for U, then U1, U2, U3, U4, and U5 are matched with the words to be matched in the domain vocabulary database. If U1 matches the word to be matched, while U2, U3, U4, and U5 do not, then the word to be matched by U1 is taken as the domain vocabulary. If U1 and U5 match the word to be matched, then the word to be matched by U1 and the word to be matched by U2 are taken as the domain vocabulary in the translation prediction result. If none of U1, U2, U3, U4, and U5 match the word to be matched, then it is determined that there is no domain vocabulary in the translation vocabulary prediction result, and the translation vocabulary with the highest predicted probability in the translation vocabulary prediction result can be directly selected as the translation vocabulary of the segmentation object.
[0117] 105: Based on the translation vocabulary prediction results and domain vocabulary, output the translated text of the text to be translated.
[0118] Once the domain vocabulary in the translation vocabulary prediction results is determined, the target translation vocabulary that matches the domain vocabulary in the translation vocabulary prediction results can be replaced with the domain vocabulary. The domain vocabulary is then used as the translation vocabulary of the segmentation object corresponding to the translation vocabulary. This process is repeated to obtain the translation vocabulary of each segmentation object. Each translation vocabulary is then sorted based on the order of each segmentation object in the text to be translated, resulting in the translation text of the text to be translated.
[0119] For example, assuming the predicted translation vocabulary for the segmented object includes U = (U1, U2, U3, U4, U5) and the predicted probability P = (P1, P2, P3, P4, P5) for U, then U1, U2, U3, U4, and U5 are matched with the words to be matched in the domain vocabulary database. If U1 matches a word to be matched, while U2, U3, U4, and U5 do not, then the word to be matched by U1 is taken as the domain vocabulary, and this domain vocabulary is taken as the translation vocabulary for the segmented object. The translated text with the translated text is obtained. If U1 and U5 match the words to be matched, while U2, U3 and U4 do not match the words to be matched, further, if the prediction probability of U1 is greater than or equal to the prediction probability of U2, then the words to be matched by U1 are taken as the domain words in the translation prediction result. If the prediction probability of U2 is greater than the prediction probability of U1, then the words to be matched by U2 are taken as the domain words in the translation prediction result, and the domain words are taken as the translation words of the segmentation object, thus obtaining the translated text of the text to be translated.
[0120] The target translation words and their predicted probabilities can be selected from the translation word prediction results. These target translation words are then matched with words to be matched. If a word to be matched matches the target translation word, the translation word prediction results are updated based on a preset enhancement coefficient and the word to be matched, thereby determining the domain vocabulary. That is, optionally, in some embodiments, the step "determining the domain vocabulary in the translation word prediction results based on the translation word prediction results and a preset domain vocabulary database" further includes:
[0121] (61) Extract a preset number of target translation words and the predicted probability of the target translation words from the translation word prediction results;
[0122] (62) Match each target translation term with each term to be matched in the domain term database;
[0123] (63) If there is a word to be matched that matches the target word, then update the word prediction result based on the preset enhancement coefficient and the word to be matched;
[0124] (64) Select the target translation word with the highest prediction probability from the translation word prediction results as the domain word.
[0125] For example, assuming the predicted translation vocabulary of the segmented object includes U = (U1, U2, U3, U4, U5) and the predicted probability P = (P1, P2, P3, P4, P5) corresponding to U, then U1, U2, U3, U4, and U5 are matched with the words to be matched in the domain vocabulary database. If U1 and U5 match the words to be matched, but U2, U3, and U4 do not match the domain words to be matched, then U1 and its predicted probability are updated based on the words to be matched matched by U1 and the preset enhancement coefficient, and U5 and its predicted probability are updated based on the words to be matched matched by U5 and the preset enhancement coefficient, thereby updating the prediction results of the translation vocabulary. Finally, the target translation vocabulary with the highest predicted probability is selected as the domain vocabulary from the updated prediction results.
[0126] Optionally, the predicted probabilities of the translated words in the translation word prediction results can be updated according to the following formula (9):
[0127] P i = (1+β)P i (9)
[0128] In the formula, P i ' is the updated predicted probability of the i-th translated word, P i Let β be the prediction probability of the i-th translation word, and let β be the preset enhancement coefficient, which can be 0.2. The enhancement coefficient is determined according to the actual application scenario and is not specifically limited here.
[0129] Optionally, in scenarios involving Chinese-English bilingual translation, such as Figure 4As shown, assuming the text to be translated is "This is a synchronous machine", after segmenting the text, multiple segmentation objects are obtained (i.e., the segmentation results shown in the figure). These segmentation objects include "this is", "a", and "synchronous machine". The predicted translation words for "this is" are "This is", the predicted translation words for "a" are "a", and the predicted translation words for "synchronous machine" include Machine, synchronous-machine, synchronous, this, and and, with corresponding prediction probabilities of 0.311, 0.265, 0.253, 0.036, and 0.005, respectively. When the domain word "synchronous-machine" is included in the predicted translation words, an enhancement coefficient is introduced, and the prediction probability of "synchronous-machine" is recalculated to 0.318, thereby updating the predicted translation words. The target translation word corresponding to the highest prediction probability is selected from the predicted translation words as the domain word, resulting in the translated text "This is asynchronous-machine".
[0130] The above is the text translation process for this application.
[0131] As described above, this application provides a text translation method, apparatus, computer device, and storage medium. The method involves acquiring the text to be translated and segmenting it to obtain multiple segmentation objects. Each segmentation object is then encoded to obtain a segmentation object encoding vector. The translation vocabulary for each segmentation object's encoding vector is predicted, resulting in a translation vocabulary prediction result for each segmentation object. Based on the translation vocabulary prediction result and a pre-set domain vocabulary database, domain vocabulary is determined from the translation vocabulary prediction result. Finally, based on the translation vocabulary prediction result and the domain vocabulary, the translated text of the text to be translated is output. In the text translation scheme provided by this application, by predicting the translation vocabulary prediction results for multiple segmentation objects of the text to be translated, and then determining the domain vocabulary from the translation vocabulary prediction results, the translated text of the text to be translated is output based on each translation vocabulary prediction result and the domain vocabulary. Therefore, outputting the translated text of the text to be translated based on the translation vocabulary prediction result for each segmentation object and the domain vocabulary in the translation vocabulary prediction result can avoid the problem of inaccurate translation caused by the scarcity of domain vocabulary in professional fields when using machine translation, thus improving the accuracy of vocabulary translation.
[0132] It should be understood that the sequence number of each step in the above embodiments does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present invention.
[0133] In one embodiment, a text translation apparatus is provided, which corresponds one-to-one with the text translation methods described in the above embodiments. Please refer to [link / reference]. Figure 4 As shown, the text translation device includes an acquisition module 201, an encoding module 202, a prediction module 203, a determination module 204, and an output module 205. Detailed descriptions of each functional module are as follows:
[0134] The acquisition module 201 is used to acquire the text to be translated and segment the text to be translated to obtain multiple segmentation objects corresponding to the text to be translated.
[0135] Encoding module 202 is used to encode each segmentation object to obtain the segmentation object encoding vector for each segmentation object;
[0136] Prediction module 203 is used to predict the translation vocabulary of the encoding vector of each segmented object, and obtain the translation vocabulary prediction result of each segmented object;
[0137] The determination module 204 is used to determine the domain words in the translation word prediction results based on the translation word prediction results and a preset domain word database;
[0138] Output module 205 is used to output the translated text of the text to be translated based on the translation vocabulary prediction results and domain vocabulary.
[0139] Optionally, in some embodiments, the prediction module includes:
[0140] The annotation submodule is used to label each segmentation object and obtain the label for each segmentation object.
[0141] The first encoding submodule is used to encode each tag to obtain the tag encoding vector corresponding to each tag;
[0142] The submodule is used to obtain the fusion vector information of each segmentation object based on the encoding vector of each segmentation object and the encoding vector of each label;
[0143] The second encoding submodule is used to encode each fused vector information to obtain word vector representation information;
[0144] The prediction submodule is used to predict the translation vocabulary for each word vector representation information, and obtain the translation vocabulary prediction result for each segmented object.
[0145] Optionally, in some embodiments, the first encoding submodule includes:
[0146] The acquisition unit is used to acquire the preset dimension encoding vector corresponding to each label;
[0147] The encoding unit is used to encode the label using a preset dimension encoding vector to obtain the label encoding vector corresponding to the label.
[0148] Optionally, in some embodiments, the obtained submodule includes:
[0149] The transformation unit is used to perform a linear transformation on the label encoding vector to obtain the hidden layer vector corresponding to the label encoding vector.
[0150] The computation unit is used to compute the cross-attention information between the hidden layer vector and the segmentation object encoding vector;
[0151] The weighting unit is used to weight the cross-attention information and the segmentation object encoding vector to obtain the fused vector information.
[0152] Optionally, in some embodiments, the prediction submodule includes:
[0153] The update unit is used to update the state of each word vector representation information to obtain each updated word vector representation information.
[0154] The first prediction unit is used to predict the translation vocabulary for each updated word vector representation information, and obtain the translation vocabulary prediction result for each segmented object.
[0155] Optionally, in some embodiments, the prediction submodule includes:
[0156] The decoding unit is used to decode the word vector representation information of each word to obtain the decoded representation vector of each segmented object;
[0157] The second prediction unit is used to predict the translation vocabulary for each decoded representation vector, thus obtaining the translation vocabulary prediction result for each segmented object.
[0158] Optionally, in some embodiments, the determining module includes:
[0159] The extraction submodule is used to extract a preset number of target translation words and their predicted probabilities from the translation word prediction results.
[0160] The matching submodule is used to match each target translation term with each term to be matched in the domain terminology database;
[0161] The update submodule is used to update the translation word prediction results based on the preset enhancement coefficient and the word to be matched if there is a word to be matched that matches the target translation word.
[0162] The selection submodule is used to select the target translation word with the highest predicted probability from the translation word prediction results, and use it as the domain word.
[0163] In one embodiment, a computer device is provided, the internal structure of which can be as follows: Figure 5 As shown, the computer device includes a processor, memory, network interface, display screen, and input devices connected via a system bus. The processor provides computational and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The network interface is used to communicate with an external server via a network connection. When executed by the processor, the computer program implements the functions or steps of a text translation method.
[0164] In one embodiment, a computer device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to perform the following steps:
[0165] Obtain the text to be translated and segment it to obtain multiple segmentation objects corresponding to the text to be translated;
[0166] Encode each segmentation object to obtain the segmentation object encoding vector for each segmentation object;
[0167] Predict the translation vocabulary for the encoding vector of each segmented object to obtain the translation vocabulary prediction result for each segmented object;
[0168] Based on the translation vocabulary prediction results and the pre-set domain vocabulary database, the domain vocabulary in the translation vocabulary prediction results is determined;
[0169] Based on the translation vocabulary prediction results and domain vocabulary, the translated text of the text to be translated is output.
[0170] In this embodiment, the translation vocabulary prediction results of multiple segmented objects of the text to be translated are predicted, and then the domain vocabulary in the translation vocabulary prediction results is determined. Based on each translation vocabulary prediction result and the domain vocabulary, the translated text of the text to be translated is output. It is evident that outputting the translated text of the text to be translated based on the translation vocabulary prediction results of each segmented object and the domain vocabulary in the translation vocabulary prediction results can avoid the problem of inaccurate translation caused by the scarcity of domain vocabulary in professional fields when using machine translation, thus improving the accuracy of vocabulary translation.
[0171] In one embodiment, a computer-readable storage medium is provided, which stores a computer program that, when executed by a processor, performs the following steps:
[0172] Obtain the text to be translated and segment it to obtain multiple segmentation objects corresponding to the text to be translated;
[0173] Encode each segmentation object to obtain the segmentation object encoding vector for each segmentation object;
[0174] Predict the translation vocabulary for the encoding vector of each segmented object to obtain the translation vocabulary prediction result for each segmented object;
[0175] Based on the translation vocabulary prediction results and the pre-set domain vocabulary database, the domain vocabulary in the translation vocabulary prediction results is determined;
[0176] Based on the translation vocabulary prediction results and domain vocabulary, the translated text of the text to be translated is output.
[0177] In this embodiment, the translation vocabulary prediction results of multiple segmented objects of the text to be translated are predicted, and then the domain vocabulary in the translation vocabulary prediction results is determined. Based on each translation vocabulary prediction result and the domain vocabulary, the translated text of the text to be translated is output. It is evident that outputting the translated text of the text to be translated based on the translation vocabulary prediction results of each segmented object and the domain vocabulary in the translation vocabulary prediction results can avoid the problem of inaccurate translation caused by the scarcity of domain vocabulary in professional fields when using machine translation, thus improving the accuracy of vocabulary translation.
[0178] It should be noted that the functions or steps that can be implemented by the computer-readable storage medium or computer device described above can be referred to the relevant descriptions on the server side and client side in the foregoing method embodiments. To avoid repetition, they will not be described one by one here.
[0179] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium. When executed, the computer program can include the processes of the embodiments of the above methods. Any references to memory, storage, databases, or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in various forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), dual data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), RAMbus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and RAMbus dynamic RAM (RDRAM), etc.
[0180] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the above-described division of functional units and modules is used as an example. In practical applications, the above functions can be assigned to different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above.
[0181] The above embodiments are only used to illustrate the technical solutions of the present invention, and are not intended to limit it. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention, and should all be included within the protection scope of the present invention.
Claims
1. A text translation method, characterized in that, include: Obtain the text to be translated, and segment the text to be translated to obtain multiple segmentation objects corresponding to the text to be translated; Each segmented object is encoded to obtain a segmented object encoding vector for each segmented object; Predict the translation vocabulary for each segmented object's encoding vector to obtain the translation vocabulary prediction result for each segmented object; Based on the translation vocabulary prediction results and the preset domain vocabulary database, the domain vocabulary in the translation vocabulary prediction results is determined; Based on the translation vocabulary prediction results and the domain vocabulary, the translated text of the text to be translated is output.
2. The text translation method according to claim 1, characterized in that, The process of predicting the translation vocabulary for each segmented object's encoding vector to obtain the translation vocabulary prediction result for each segmented object includes: Each segmented object is labeled to obtain a label for each segmented object; Each of the tags is encoded to obtain a tag encoding vector corresponding to each tag; Based on the encoding vector of each segmented object and the encoding vector of each label, the fusion vector information of each segmented object is obtained; Each of the fused vector information is encoded to obtain word vector representation information; Predict the translation vocabulary for each of the word vector representations to obtain the translation vocabulary prediction result for each segmentation object.
3. The text translation method according to claim 2, characterized in that, The step of encoding each of the tags to obtain a tag encoding vector corresponding to each tag includes: Obtain the preset dimension encoding vector corresponding to each of the labels; The label is encoded using the preset dimension encoding vector to obtain the label encoding vector corresponding to the label.
4. The text translation method according to claim 2, characterized in that, The step of obtaining the fusion vector information of each segmented object based on the encoding vector of each segmented object and the encoding vector of each label includes: A linear transformation is performed on the tag encoding vector to obtain the hidden layer vector corresponding to the tag encoding vector; Calculate the cross-attention information between the hidden layer vector and the segmentation object encoding vector; The cross-attention information and the segmentation object encoding vector are weighted to obtain the fusion vector information.
5. The text translation method according to claim 2, characterized in that, The process of predicting the translation vocabulary for each word vector representation information to obtain the translation vocabulary prediction result for each segmented object includes: The state of each word vector representation information is updated to obtain each updated word vector representation information; Predict the translation vocabulary for each of the updated word vector representations to obtain the translation vocabulary prediction result for each segmented object.
6. The text translation method according to claim 2, characterized in that, The process of predicting the translation vocabulary for each of the word vector representations to obtain the translation vocabulary prediction result for each segmented object includes: Decode each word vector representation information to obtain the decoded representation vector of each segmented object; Predict the translation vocabulary for each of the decoded representation vectors to obtain the translation vocabulary prediction result for each segmented object.
7. The text translation method according to any one of claims 1 to 6, characterized in that, The process of determining the domain terms in the translation term prediction results based on the predicted translation terms and a preset domain term database includes: Extract a preset number of target translation words and their predicted probabilities from the translation word prediction results; The target translation terms are matched with the terms to be matched in the domain terminology database. If there is a match between the word to be matched and the target translation word, then the translation word prediction result is updated based on the preset enhancement coefficient and the word to be matched. The target translation word with the highest predicted probability is selected from the translation word prediction results and used as the domain word.
8. A text translation device, characterized in that, The device includes: The acquisition module is used to acquire the text to be translated and segment the text to be translated to obtain multiple segmentation objects corresponding to the text to be translated; The encoding module is used to encode each of the segmented objects to obtain a segmentation object encoding vector for each of the segmented objects; The prediction module is used to predict the translation vocabulary of the encoding vector of each segmented object, and obtain the translation vocabulary prediction result of each segmented object; The determination module is used to determine the domain words in the translation word prediction results based on the translation word prediction results and a preset domain word database; The output module is used to output the translated text of the text to be translated based on the translation vocabulary prediction results and the domain vocabulary.
9. A computer 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 computer program, it implements the steps of the text translation method as described in any one of claims 1 to 7.
10. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the text translation method as described in any one of claims 1 to 7.