A prompt-based machine translation method

By constructing noun translation prompts and adjusting the attention of the machine translation model using an adjustment matrix, the problems of omission and mistranslation of nouns and proper nouns were solved, achieving higher translation accuracy.

CN115906878BActive Publication Date: 2026-03-06BEIJING ZHONGKE ZHIJIA TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211347974.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-10-31
Publication Date
2026-03-06
Estimated Expiration
2042-10-31

AI Technical Summary

Technical Problem

Existing machine translation models suffer from omissions and mistranslations when translating nouns and proper nouns, especially in less common languages ​​and when training samples are limited.

Method used

By constructing input data containing noun translation prompts and an adjustment matrix, the attention calculation of the translation model is adjusted to focus on the attention between the noun and the original noun. The accuracy of noun translation is improved by using a noun translation dictionary and a similarity algorithm.

Benefits of technology

It improves the accuracy of machine translation models in translating nouns and proper nouns, solves the problems of omissions and mistranslations, and enhances the accuracy of translation.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115906878B_ABST
    Figure CN115906878B_ABST
Patent Text Reader

Abstract

This invention relates to a prompt-based machine translation method, belonging to the field of natural language processing technology. It solves the problems of inaccurate, omitted, and mistranslated nouns and proper nouns in existing machine translation models. By constructing a set of nouns and their translations from the text to be translated, the input text and adjustment matrix of the translation model are obtained. The translation model is then used to translate the input text, and the attention calculation of the model is adjusted using the adjustment matrix M, ultimately outputting the translation. Based on the input data containing noun translation prompts and the adjustment matrix, the accuracy of the noun translation by the translation model is guaranteed to a certain extent, solving the problems of omitted and mistranslated nouns, and improving the accuracy of noun translation in machine translation models.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of natural language processing technology, and in particular to a prompt-based machine translation method. Background Technology

[0002] Machine translation, also known as automatic translation, is an important area of ​​artificial intelligence. It involves using computers to convert one natural language (source language) into another natural language (target language). With economic globalization and the rapid development of the internet, machine translation technology is playing an increasingly important role in promoting political, economic, and cultural exchanges between countries. Therefore, research on machine translation technology has significant practical implications.

[0003] When machine translation technology was first proposed, the method used was statistical machine translation (SMT). This method treated translation as a probabilistic problem, directly using statistical results for ambiguity resolution and translation selection, thus avoiding the difficulties of language understanding. However, due to the enormous workload of corpus selection and processing, general-purpose machine translation systems rarely rely primarily on statistical methods. In recent years, neural machine translation (NMT), based on deep learning networks, has become widely used. Its multi-layered network structure can effectively learn the contextual information of the source text, extract semantic features, and generate more fluent and standardized translations, resulting in a "leapfrog" improvement in machine translation quality.

[0004] However, deep learning-based methods also have some drawbacks, the most significant being inaccurate translation of nouns and proper nouns. Inaccurate translation of nouns and proper nouns includes two aspects: omission (skipping certain nouns or sections without translating them) and mistranslation (translation errors). Omission is particularly severe when translating less common languages ​​or when training samples are limited. Since current machine translation models all suffer from inaccurate translation of nouns and proper nouns, including omissions and mistranslations, there is an urgent need for machine translation models that ensure accurate noun translation. Summary of the Invention

[0005] Based on the above analysis, the embodiments of the present invention aim to provide a prompt-based machine translation method to solve the problems of inaccurate translation, omission, and mistranslation of nouns and proper nouns in existing machine translation models.

[0006] On one hand, embodiments of the present invention provide a prompt-based machine translation method, comprising the following steps:

[0007] Obtain the text x to be translated, and identify the set S of nouns included in the text to be translated. word ;

[0008] Obtain the set of nouns S word The translations of all nouns in the text form a translation set S. word-trans ;

[0009] Text to be translated x, set of nouns S word and the set of noun translations S word-trans Through data construction, the input text x of the translation model is obtained. input and the adjustment matrix M of the translation model; wherein, the input text includes prompts, the prompts being a set of noun translations S. word-trans All translations in;

[0010] Using a translation model for x input The translation is performed, and the attention calculation of the model is adjusted using the adjustment matrix M, and the final translation is output.

[0011] Furthermore, the data construction includes the following steps:

[0012] The text to be translated is cleaned to obtain the cleaned text x0;

[0013] The text x0 is followed by a set of noun translations S. word-trans All the translations in the model are used to obtain the input text x for the translation model. input ;

[0014] Construct the input text x input List of corresponding positional relationships index According to the list index Determine the values ​​M of the elements in the adjustment matrix. ij Special symbols are inserted into the starting and ending rows and columns to obtain the adjustment matrix M.

[0015] Furthermore, the translation model is trained through the following steps:

[0016] Obtain parallel corpus data for the two languages ​​to be translated, resulting in dataset D;

[0017] The original text and translated text in the dataset D are identified, resulting in the original text noun set S. word and the set of translated nouns S word-trans ;

[0018] The training samples X of all data in D are obtained through data construction. input The adjustment matrix M corresponding to all data train , where X input =[x1,x2,…,x g ], M train=[M1,M2,…,M g ], a single training sample x i i∈[1,2,…,g] is the text x after adding translation prompts. input and target translation x gold The text pairs, where g is the number of data entries;

[0019] X input Divided into training set D train Validation set D valid Test set D test The adjustment matrix M train Import the translation model and use D train The model is trained, and D is used at the end of each training round. valid The model is validated, and the model with the best validation result is taken as the final model.

[0020] Furthermore, construct a list of the corresponding positional relationships of the text. index It includes the following steps:

[0021] The input text x of the translation model input Each pair of nouns and their translations is in x input The position in the middle is represented by a pair of tuples;

[0022] Each noun-translation position tuple forms a sublist;

[0023] Concatenate all sublists containing noun-translation position tuples to form a list of corresponding positional relationships in the text. index .

[0024] Furthermore, the adjustment matrix element M ij The possible values ​​and constraints are as follows:

[0025]

[0026] Where len(x0) represents the length of the original text x0 after cleaning and before adding translation prompts, len(List index ) represents the list. index The length of the List index [z][0] represents List index The first tuple in the z-th sublist of the List index [z][1] represents List index The second tuple in the z-th sublist.

[0027] Furthermore, the attention of the model after importing the adjustment matrix M is calculated using the following function:

[0028]

[0029] Where Q, K, and V are the Query, Key, and Value matrices in the self-attention mechanism, respectively, and d k It is the dimension of Q or K.

[0030] Furthermore, the import adjustment matrix M includes:

[0031] According to the preset maximum input length L of the model. max By adding elements with zero values, the adjustment matrix M is expanded to the right and downward to a size of L. max ×L max We obtain M';

[0032] Import M' into the model encoding layer.

[0033] Furthermore, the adjustment matrix M is calculated using the following function. train Post-model attention:

[0034]

[0035] Q i K i V i It is to calculate x i Query, Key, and Value matrix during attention. It is Q i or K i The dimension (both are the same), is generally taken as d. k =64;

[0036] The prediction result x is calculated using the following function. pred and target result x gold Losses between:

[0037] Loss = CrossEntropy(x pred x gold )

[0038] Minimize the loss and update the model weights, training until the loss no longer decreases;

[0039] The accuracy of the model's translation is calculated using the following function:

[0040]

[0041] Where, p n For the predicted result x pred The proportion of correctly predicted n-grams, i.e.

[0042]

[0043] BP is a penalty factor that penalizes the predicted outcome x. pred The length of x gold Case with short length:

[0044]

[0045] Furthermore, obtain the noun set S. word ,include:

[0046] Utilizing built-in part-of-speech tagging tools; and

[0047] Use a noun recognition model that has been trained according to requirements.

[0048] Furthermore, obtain the translation set S. word-trans ,include:

[0049] 1) Obtain the noun w to be matched;

[0050] 2) Use 'w' as the key to directly query the dictionary dict. noun If a corresponding value exists, use that value directly as the translation; otherwise, proceed to the next step.

[0051] 3) Calculate the match between the noun w to be matched and the dictionary dict. noun All keys key = {key1, key2, ..., key x The similarity scores of} are used to obtain the score set S = {s1, s2, ..., s}. x}, where x is a dict noun length

[0052] 4) Find the position of the element with the largest value in the score set S. If the number of the largest elements in S is greater than 1, then randomly select one of the elements as the element with the largest value.

[0053] 5) Find the corresponding dictionary (dict) based on the position of the element with the largest value. noun key-value pairs in max and value max Using value max As a translation.

[0054] Compared with the prior art, the present invention can achieve at least one of the following beneficial effects:

[0055] 1. By constructing input data and an adjustment matrix that include noun translation prompts, the translation model can accurately translate nouns, solving the problems of inaccurate, missed, and incorrect translations of nouns and proper nouns in existing translation models.

[0056] 2. By constructing an adjustment matrix to adjust the attention calculation of the model, the model no longer calculates the attention between the translated noun and other characters in the original text, but only the attention between the translated noun and the noun in the original text, thus improving the accuracy of the model.

[0057] 3. By training the translation model with a training set containing noun translation prompts and an adjustment matrix beforehand, the model learns the inherent connection between nouns and their translations, thus improving the accuracy of the translation model for prompt-based noun translation.

[0058] In this invention, the above-described technical solutions can be combined with each other to achieve more preferred combinations. Other features and advantages of this invention will be set forth in the following description, and some advantages may become apparent from the description or be learned by practicing the invention. The objects and other advantages of this invention can be realized and obtained from what is particularly pointed out in the description and drawings. Attached Figure Description

[0059] The accompanying drawings are for illustrative purposes only and are not intended to limit the invention. Throughout the drawings, the same reference numerals denote the same parts.

[0060] Figure 1 This is a flowchart of a prompt-based machine translation method according to an embodiment of the present invention;

[0061] Figure 2 This is a schematic diagram of the module structure of the prompt-based machine translation method according to an embodiment of the present invention;

[0062] Figure 3 This is a schematic diagram of the method for constructing the adjustment matrix according to an embodiment of the present invention; Detailed Implementation

[0063] Preferred embodiments of the present invention will now be described in detail with reference to the accompanying drawings, which form part of this application and are used together with the embodiments of the present invention to illustrate the principles of the present invention, but are not intended to limit the scope of the present invention.

[0064] A specific embodiment of the present invention, such as Figure 1 As shown, a prompt-based machine translation method is disclosed, including:

[0065] Step S110: Obtain the text to be translated x, and identify the set of nouns S included in the text to be translated. word Specifically, the text to be translated can be input into a noun recognition module for noun recognition, resulting in a noun set S. word。

[0066] Step S120: Obtain the noun set S wordThe translations of all nouns in the text form a translation set S. word-trans Specifically, you can use the built-in noun translation dictionary in the noun search module to retrieve S. word The translations of all nouns in the text.

[0067] Step S130, text to be translated x, set of nouns S word and the set of noun translations S word-trans Through data construction, the input text x of the translation model is obtained. input and the adjustment matrix M of the translation model; wherein, the input text includes prompts, the prompts being a set of noun translations S. word-trans All translations in the document.

[0068] Step S140: Use the translation model to analyze x. input The translation process involves adjusting the attention calculation of the model using an adjustment matrix M, ultimately outputting the translated text. Specifically, after adjustment using the adjustment matrix, the translation model, during attention calculation, does not calculate the attention between the translated nouns and other source text characters, but only the attention between nouns in the source text.

[0069] This invention constructs a dictionary of nouns for the target language beforehand. Before translation, the nouns in the text to be translated are found, and the corresponding translation words are added to the dictionary as input prompts for the text to be translated. This creates the dataset required for the translation model to accurately translate nouns. During training, an adjustment matrix is ​​used to prevent the model from learning the relationships between translation words, allowing the model to focus more on the translation task. Through the prompts for noun translation, the accuracy of noun translation is guaranteed to a certain extent, solving the problems of omission and mistranslation of nouns.

[0070] In one specific embodiment, the noun recognition module in step S110 above is either a built-in part-of-speech tagging tool or a pre-trained noun recognition model. Optionally, the built-in part-of-speech tagging tool is the jieba word segmentation toolkit.

[0071] In one specific embodiment, the term query module in step S120 above includes a term dictionary and a query program;

[0072] The terminology dictionary is a dictionary containing all the terms that the user needs. The keys of the dictionary are the terms represented in the language to be translated, and the values ​​are the corresponding terms represented in the target language.

[0073] For example, the data structure of a dictionary (Chinese to English) is as follows:

[0074] dictnoun = {"China":"China","United States":"America",……}

[0075] Optionally, users can build a noun dictionary by using existing resources or by building it themselves.

[0076] The query program uses an imprecise matching method; preferably, it uses a text similarity algorithm for matching.

[0077] Furthermore, the text similarity algorithm matching steps include:

[0078] 1. Using any noun w to be matched as the key, directly query the dictionary dict. noun If a corresponding value exists, use that value directly as the translation; otherwise, proceed to the next step.

[0079] 2. Calculate the match between the noun w to be matched and the dictionary dict. noun All keys key = {key1, key2, ..., key x The similarity scores of} are used to obtain the score set S = {s1, s2, ..., s}. x}, where x is a dict noun The length of the similarity score; the formula for calculating the similarity score is:

[0080]

[0081] Where len(w) is the length of word w, and len(key) is the length of word w. i Let ) represent the length of the i-th key, exp(·) be the function to calculate the expected value, and count be... same For w and key i The number of overlapping grams in an n-gram, count n-gram Let w be the number of grams in n-gram, where n is between 1 and 3.

[0082] 3. Find the position of the element with the largest value in the score set S. If the number of elements with the largest value in S is greater than 1, then randomly select one of the elements as the element with the largest value.

[0083] 4. Find the corresponding dictionary (dict) based on the position of the element with the largest value. noun key-value pairs in max and value max Using value max As a translation.

[0084] In a specific embodiment, the data construction described in step S130 above includes: data cleaning, constructing the input text for the translation model, and constructing the adjustment matrix;

[0085] The data cleaning process involves cleaning the original text to be translated to obtain the cleaned text x0. The cleaning process includes: removing spaces and redundant invalid characters; and unifying simplified and traditional Chinese characters (if Chinese characters are involved).

[0086] The input text for constructing the translation model includes: sequentially concatenating the set of noun translations S after the cleaned text x0. word-trans All translations, separated by spaces, form the input text x for the translation model. input ;

[0087] The construction of the adjustment matrix includes: constructing a list of corresponding positional relationships of the input text; and constructing an L×L adjustment matrix M based on the list.

[0088] Wherein, the list of corresponding positional relationships of the input text is constructed. index The steps include:

[0089] The input text x of the translation model input Each noun or its translation in x input The position in the text is represented by a tuple; each noun-translation position tuple forms a sublist; concatenating all noun-translation position tuples forms a large list, which is the List. index For example, Table 1 shows a method for constructing a list of input text and corresponding positional relationships.

[0090] Table 1. Examples of constructing a list of correspondences between input text and location.

[0091]

[0092]

[0093] It should be noted that the above List indesx The position shown is just an example; in actual operation, it is necessary to consider X. input The word segmentation results have been adjusted. Here, Chinese text is segmented by single character and English text is segmented by word by default. Spaces between English words are not counted in the word segmentation.

[0094] The L×L adjustment matrix M is constructed as follows: Figure 3 As shown, it includes: based on the list List index Determine the values ​​of the elements in the adjustment matrix M; insert special symbols into the first and last rows and columns of the matrix, such that L = len(x input +2; Optionally, the special symbols inserted in the starting row and ending row of the matrix are [CLS] and [SEP], respectively;

[0095] Furthermore, the element M in the i-th row and j-th column of M... i,j The possible values ​​and constraints are as follows:

[0096] (1) M is M when i and j satisfy any of the following conditions respectively. i,j =0;

[0097] Condition 1: Less than or equal to len(x0) + 1

[0098] Condition 2: equal to L

[0099] (2) When i and j belong to List index A sublist of List one The two tuples in List one [0] and List one [1] when M i,j =0;

[0100] (3) In other cases, M i,j It is negative infinity (-∞);

[0101] Alternatively, use 1e-4 or 1e-9 instead of negative infinity (-∞);

[0102] Optionally, when 1e-4 is used instead of negative infinity (-∞), M i,j The expression for the value of is as follows:

[0103]

[0104] Where len(x0) represents the length of the original text x0 after cleaning and before adding prompts, len(List index ) represents a List index The length of the List (the number of sublists). index [z][0] represents List index The first tuple in the z-th sublist of the List index [z][1] represents List index The second tuple in the z-th sublist.

[0105] In one specific embodiment, the translation model employs the neural machine translation model NPTrans. For example... Figure 2 As shown, step S140 above can be optimized into the following steps:

[0106] Step S210: Import the adjustment matrix M into the encoding layer of the neural machine translation model NPTrans to adjust the calculation of the parameters within the model;

[0107] Specifically, the adjustment matrix M is imported into the encoding layer of the neural machine translation model NPTrans, including: according to the preset maximum input length L of the neural machine translation model NPTrans. max By adding elements with zero values, the adjustment matrix M is expanded to the right and downward to a size of L. max ×L max M' is obtained; M' is then imported into the encoding layer.

[0108] Specifically, the neural machine translation model NPTrans is built using the transformers framework, including an encoder and a decoder. Both the encoder and decoder contain multiple layers of the same self-attention residual structure, and an adjustment matrix is ​​added to calculate self-attention. The calculation formula is as follows:

[0109]

[0110] Where Q, K, and V are the Query, Key, and Value matrices in the self-attention mechanism, respectively, and d k It is the dimension of Q or K (the two are the same).

[0111] Preferably, both the encoder and the decoder contain 12 identical self-attention residual structures;

[0112] Preferably, the dimension of the Query or Key in the self-attention mechanism is d. k =64.

[0113] For example, such as Figure 3 After adding the adjustment matrix M', the neural machine translation model NPTrans will not calculate the attention between the noun translation and other source text characters (gray area), but only the attention between the noun translation and the nouns in the source text (a in the figure). 1,11 a 2,11 a 4,12 a 4,12 (Four), the remaining white parts are the attention between the original x0.

[0114] Specifically, the neural machine translation model NPTrans is trained through the following steps:

[0115] 1) Obtain parallel corpus data for the two languages ​​to be translated, resulting in dataset D;

[0116] 2) Use the noun recognition module to identify the original text and translation in D, and obtain the set of nouns in the original text S. word and the set of translated nouns S word-trans Specifically, you can use the built-in noun translation dictionary in the noun search module to retrieve S.word The noun translations corresponding to all nouns in dataset D are then analyzed. Next, a matching word is searched for in the translations of parallel corpora in dataset D. If a matching word exists, it is added to the set of translated nouns S. word-trans If it does not exist, remove it from the original noun set S. word Delete; preferably, through manual identification, important original nouns among words that do not match the translation of the noun, as well as the translated nouns in their corresponding parallel corpora, are selected and added to the dictionary as new words.

[0117] 3) Use the data building module to construct training samples X for all data in D. input The adjustment matrix M corresponding to all data train X input =[x1,x2,…,x g ], M train =[M1,M2,…,M g ], a single training sample x i (i∈[1,2,…,g]) is the text x after adding the prompt. input and target translation x gold The text pairs, where g is the number of data entries.

[0118] 4) X input Divided into training set D train Validation set D valid Test set D test The adjustment matrix M train Import the translation model and use D train The model is trained, and D is used at the end of each training round. valid The model is validated, and the model with the best validation result is selected as the final model. Preferably, the training set D... train Validation set D valid Test set D test The ratio is 8:1:1.

[0119] Furthermore, during training, for each text x i The attention of the text in the encoder is calculated using the following formula:

[0120]

[0121] Q i K i V i It is to calculate x i Query, Key, and Value matrix during attention. It is Q i or K i The dimension (both are the same), is generally taken as d. k=64.

[0122] Prediction result x pred and target result x gold The loss function expression between them is:

[0123] Loss = CrossEntropy(x pred x gold )

[0124] Minimize the loss and update the model weights, training until the loss no longer decreases.

[0125] During validation, the BLEU score was used to calculate the accuracy of the model's translation.

[0126]

[0127] Where, p n For the predicted result x pred The proportion of correctly predicted n-grams, i.e.

[0128]

[0129] BP is a penalty factor that penalizes the predicted outcome x. pred The length of x gold Case with short length:

[0130]

[0131] After obtaining the model with the best validation results as the final model, D can be used. test Conduct the test.

[0132] Step S220: Input text x of the translation model input Input the neural machine translation model NPTrans to obtain the final output translation.

[0133] Compared with existing technologies, the prompt-based machine translation method provided in this embodiment constructs a dictionary of nouns for the target language beforehand. Before translation, it finds the nouns in the text to be translated and adds the corresponding translation words from the dictionary as input prompts for the text to be translated. This constructs the dataset required for the translation model to accurately translate nouns. During training, an adjustment matrix is ​​used to prevent the model from learning the relationships between translation words, making the model more focused on the translation task. Through prompts for noun translation, the accuracy of noun translation is guaranteed to a certain extent, solving the problems of omission and mistranslation of nouns.

[0134] Those skilled in the art will understand that all or part of the processes of the methods described in the above embodiments can be implemented by a computer program instructing related hardware, and the program can be stored in a computer-readable storage medium. The computer-readable storage medium may be a disk, optical disk, read-only memory, or random access memory, etc.

[0135] The above description is only a preferred embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any changes or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in the present invention should be included within the scope of protection of the present invention.

Claims

1. A method of prompt-based machine translation, the method comprising: The method comprises the following steps: Obtaining a text to be translated x, identifying a set of nouns S included in the text to be translated word ; obtaining the set of nouns S word The set of noun translations S is composed of the noun translations corresponding to all the noun pairs in S word-trans ; Input text x, set of nouns S word and set of translated nouns S word-trans Input text x of the translation model is obtained through data construction input and adjustment matrix M of the translation model; wherein the input text includes a prompt, and the prompt is all translations in the set of translated nouns S word-trans ​ using the translation model on x input performing translation, adjusting the attention computation of the model using the adjustment matrix M, and finally outputting the translation. The data construction comprises the following steps: Data cleaning is performed on the text to be translated to obtain cleaned text x0; The text x0 is then sequentially spliced with all the translated texts in the set S to obtain the input text x of the translation model word-trans input ;​ Construct the input text x input List of corresponding positional relationships index According to the list index Determine the values ​​M of the elements in the adjustment matrix. ij By inserting special symbols into the starting and ending rows and columns, the adjustment matrix M is obtained; The attention calculation of the model is adjusted using the adjustment matrix M, comprising introducing the adjustment matrix M into the translation model; and the attention of the model after introducing the adjustment matrix M is calculated using the following function: wherein Q, K, V are Query, Key, Value matrix in self-attention mechanism, d k is the dimension of Q or K, M' is the maximum input length preset according to the translation model, and M is the matrix after the adjustment matrix M is extended to the right and down.

2. The method according to claim 1, wherein the translation model is trained by the following steps: Parallel corpus data of two languages required for translation is obtained to obtain a data set D; identifying source and target in the dataset D, obtaining a set of source nouns S word and a set of target noun translations S word-trans ; The training sample X of all data in D is obtained by data construction input The adjustment matrix M corresponding to all data train Wherein, X input = [x1, x2, …, x g ], M train = [M1, M2, …, M g ], a single training sample x i is the text pair of the input text x input and the target translation x gold after increasing the translation prompt, i∈[1,2,…,g], g is the number of data X input is divided into a training set D train , a validation set D valid , and a test set D test , the adjustment matrix M train is imported into the translation model, the model is trained with D train , the validation is performed with D valid at the end of each training round, and the model with the best validation result is taken as the final model.

3. The method according to claim 1, characterized in that, constructing a list List of corresponding positional relationships of said text index comprising the steps of: input text x to the translation model input Each pair of a noun and its translation in x input is represented by a pair of tuples; Each noun-translation position tuple pair forms a sub-list; The sub-lists of all the noun-translation position tuples are concatenated to form a list List of the corresponding position relations of the text index .

4. The method according to claim 1 or 3, characterized in that, The values of the elements of the adjustment matrix M ij are as follows: wherein len(x0) represents the length of the original text x0 after cleaning and before adding the translation cues, len(List index ) represents the length of the list List index , i.e., the number of sublists, List index [z][0] represents the first tuple in the zth sublist of List index , List index [z][1] represents the second tuple in the zth sublist of List index , and L is the final row number and final column number of the adjustment matrix.

5. The method of claim 1, characterized in that, The introduction of the adjustment matrix M into the translation model comprises: the maximum inputtable length L preset according to the model max , by increasing 0-value elements, the adjustment matrix M is extended to the right and downward to size L max ×L max , obtaining M'; M' is introduced into the encoding layer of the translation model.

6. The method of claim 2, wherein, The import of the adjustment matrix M is calculated using the function train Attention of the post model: where Q i , K i , V i are Query, Key, Value matrices at time x i Note that Q i and K i are of dimension M i and V i is the corresponding conditioning matrix for x pred ; The prediction result x is calculated using the function pred and the target result x gold between the loss: Loss = CrossEntropy(x pred , x gold ) The loss Loss is minimized and the model weight is updated until the loss no longer decreases; The accuracy of the model translation is calculated using the following function: where p n is the proportion of n-grams in the prediction x pred that are correct, and BP is a penalty factor.

7. The method of claim 1, characterized in that, identifying a set S of nouns included in the text to be translated word , comprising: The nouns in the text to be translated are annotated using an internal part-of-speech annotation tool; or The nouns in the text to be translated are recognized using a noun recognition model trained according to requirements.

8. The method of claim 1, characterized in that, obtaining the set of nouns S word the noun translation corresponding to all the nouns in the set S, comprising: 1) Obtain a to-be-matched noun w in a noun set; 2) Directly query the dictionary dict with w as the key name noun If the corresponding value exists in the dictionary, directly take the value as the translation; if not, proceed to the next step. 3) Calculate the match between the noun w to be matched and the dictionary dict. noun All keys key = {key1, key2, ..., key x The similarity scores of} are used to obtain the score set S = {s1, s2, ..., s}. x }, where x is a dict noun Length; 4) Find the position of the element with the maximum value in the score set S, and if the number of maximum elements in S is greater than 1, randomly select one of them as the element with the maximum value. 5) Find the corresponding key-value pair key and value in the dictionary dict at the position of the element with the maximum value noun . Use value as the translation. max . max . max .

Citation Information

Patent Citations

  • Interaction cue translating method and device, storage medium and electronic equipment

    CN108009158A

  • Text translation method and device, kernel function combination method, server and medium

    CN114580443A