Machine translation method and system based on large language model
By utilizing the translation examples in large language models and bilingual datasets, the correlation scores and selection of translation examples are solved, and the problem of poor generation quality in vertical domain translation tasks is achieved, and the translation effect is significantly improved.
Patent Information
- Application Number
- CN202411664912.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-20
- Publication Date
- 2025-03-28
- Estimated Expiration
- 2044-11-20
AI Technical Summary
Existing machine translation methods do not perform well in translation tasks in certain vertical fields, especially when encountering proper nouns or professional terms that have not appeared during training, which may generate under-quality translation sentences.
By obtaining a bilingual data set containing several translation examples, the large language model is used to convert the sentences to be translated and the source statements to be translated into embedded vectors, calculate the correlation score, select the source statement with the highest correlation score and its translation statements as translation examples, and input them into the large language model to imitate the translation example for translation statements.
By using translation examples to guide the translation of large language models, the quality of translation results can be significantly improved and the translation effect can be ensured.
Smart Images

Figure CN119721064A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of natural language processing, and more specifically, to a machine translation method and system based on a large language model. Background Art
[0002] With the development of artificial intelligence, large language models (LLMs) with contextual learning capabilities have gradually come into people's view. With the rapid development of LLMs, people are paying close attention to their performance in traditional natural language tasks such as machine translation. Research in recent years has shown that LLMs have demonstrated excellent performance in the field of machine translation and have significantly reduced the consumption of manpower and material resources, which is worthy of attention.
[0003] However, LLM still has certain shortcomings in natural language processing tasks, especially translation tasks. Although LLM has been trained on a wide range of data sets and can translate sentences in the target language well, it performs poorly in translation tasks in certain vertical fields. For translation tasks in specific vertical fields, LLM may encounter proper nouns or professional terms that have not appeared in the training process. If there are no appropriate prompts to convey this information to LLM, it may make wrong judgments and generate poor quality translation sentences. In addition, the output of LLM is essentially a probabilistic model, and the prediction of the next token may be subject to many interferences, resulting in the same sentence being processed by the same LLM and producing multiple different outputs. Therefore, the diverse output of LLM may not provide the best translation results.
[0004] In summary, existing machine translation methods have the problem of poor translation effect. Summary of the invention
[0005] In order to overcome the defect of poor translation results in the above-mentioned prior art, the present invention provides a machine translation method and system based on a large language model with excellent translation effect.
[0006] In order to solve the above technical problems, the technical solution of the present invention is as follows:
[0007] Obtain a bilingual data set including a plurality of translation examples, wherein each translation example includes a source sentence and a translation sentence corresponding to the source sentence;
[0008] Get the sentence to be translated;
[0009] Using a large language model, the sentence to be translated and the source sentence in the translation example are respectively converted into embedding vectors;
[0010] Calculating a correlation score between the embedding vector corresponding to the sentence to be translated and the embedding vector corresponding to the source sentence;
[0011] Selecting the source sentences and their translated sentences with the first several largest correlation scores or correlation scores with values greater than a preset threshold as translation examples;
[0012] The translation example is input into the large language model, so that the large language model translates the sentence to be translated according to the translation example.
[0013] The present invention also proposes a machine translation system based on a large language model for implementing the above-mentioned machine translation method based on a large language model, the system comprising:
[0014] A database acquisition module is used to acquire a bilingual data set containing a plurality of translation examples, wherein each translation example includes a source sentence and a translation sentence corresponding to the source sentence;
[0015] A module for obtaining sentences to be translated, used for obtaining sentences to be translated;
[0016] An embedding vector generation module, used to convert the to-be-translated sentence and the source sentence in the translation example into embedding vectors respectively using a large language model;
[0017] A correlation score calculation module, used to calculate the correlation score between the embedding vector corresponding to the sentence to be translated and the embedding vector corresponding to the source sentence;
[0018] An example acquisition module is used to select source sentences and translation sentences with the first several largest correlation scores or correlation scores with values greater than a preset threshold as translation examples;
[0019] The translation module is used to input the translation example into the large language model, so that the large language model translates the sentence to be translated according to the translation example.
[0020] The present invention also proposes a computer device, including a memory and a processor, wherein the memory stores computer-readable instructions, and when the computer-readable instructions are executed by the processor, the processor executes the steps of the above-mentioned machine translation method based on a large language model.
[0021] Compared with the prior art, the technical solution of the present invention has the following beneficial effects:
[0022] The large language model is used to convert the sentence to be translated and the source sentence in the translation example into embedding vectors respectively, and the correlation score between the embedding vector corresponding to the sentence to be translated and the embedding vector corresponding to the source sentence is calculated, and the source sentences and their translation sentences with the first several largest correlation scores or correlation scores with values greater than a preset threshold are selected as translation examples; the large language model is used to translate the sentence to be translated according to the translation example, and the translation example highly overlaps with the sentence information to be translated, so that the translation result has excellent translation effect. BRIEF DESCRIPTION OF THE DRAWINGS
[0023] Figure 1 This is a first flow chart of the machine translation method based on a large language model proposed in Example 1;
[0024] Figure 2 This is a schematic diagram of a prompt word template containing a variable placeholder proposed in Example 1;
[0025] Figure 3 A second flow chart of the machine translation method based on a large language model proposed in Example 2;
[0026] Figure 4 A schematic diagram of the text after interference proposed in Example 2;
[0027] Figure 5 This is a schematic diagram of the reordering model training process proposed in Example 2;
[0028] Figure 6 This is a third flow chart of the machine translation method based on a large language model proposed in Example 2. DETAILED DESCRIPTION
[0029] The accompanying drawings are only used for illustrative purposes and should not be construed as limiting the present embodiment;
[0030] In order to better illustrate the present embodiment, some parts in the drawings may be omitted, enlarged or reduced, and do not represent the size of the actual product;
[0031] It is understandable to those skilled in the art that some well-known structures and their descriptions may be omitted in the drawings.
[0032] The technical solution of the present invention is further described below in conjunction with the accompanying drawings and embodiments.
[0033] Example 1
[0034] This embodiment proposes a machine translation method based on a large language model. Figure 1 1 is a schematic diagram of a first flow chart of a machine translation method based on a large language model of this embodiment;
[0035] A machine translation method based on a large language model proposed in this embodiment includes the following steps:
[0036] S1: Obtain a bilingual data set containing a plurality of translation examples, wherein each translation example includes a source sentence and a translation sentence corresponding to the source sentence;
[0037] S2: Obtain the sentence to be translated;
[0038] S3: using a large language model to convert the sentence to be translated and the source sentence in the translation example into embedding vectors respectively;
[0039] S4: Calculate the correlation score between the embedding vector corresponding to the sentence to be translated and the embedding vector corresponding to the source sentence;
[0040] S5: Selecting the source sentences and their translated sentences with the first several largest correlation scores or correlation scores with values greater than a preset threshold as translation examples;
[0041] S6: Inputting the translation example into the large language model, so that the large language model translates the sentence to be translated according to the translation example.
[0042] In the specific implementation process, the large language model is used to convert the sentence to be translated and the source sentence in the translation example into embedding vectors respectively, and the correlation score between the embedding vector corresponding to the sentence to be translated and the embedding vector corresponding to the source sentence is calculated, and the source sentences and their translation sentences with the first several largest correlation scores or correlation scores greater than a preset threshold are selected as translation examples; the large language model is used to translate the sentence to be translated according to the translation example, and the translation example highly overlaps with the information of the sentence to be translated, so that the translation effect of the translation result is excellent.
[0043] In an optional embodiment, when using a large language model to convert the sentence to be translated and the source sentence in the translation example into embedding vectors respectively, the sentence to be translated and the source sentence in the translation example are respectively input into the large language model, and the embedding layer of the large language model converts the sentence to be translated and the source sentence in the translation example into embedding vectors respectively.
[0044] In an optional embodiment, when calculating the correlation score between the embedding vector corresponding to the sentence to be translated and the embedding vector corresponding to the source sentence, the expression of the correlation score includes:
[0045] S rank =α 1 ×S dense +α 2 ×S spare +α 3 ×S multi
[0046]
[0047]
[0048]
[0049] In the formula, α 1 Indicates S dense The weight, α 2 Indicates S spare The weight, α 3 Indicates S multi The weight of q represents the sentence to be translated, and p represents any source sentence in the bilingual dataset. represents the dense embedding vector corresponding to sentence q, represents the dense embedding vector corresponding to sentence p, q∩p represents the set of all co-occurring tokens of sentence q and sentence p, t represents any element in q∩p, represents the weight corresponding to the tag t in the sentence q, represents the weight corresponding to the tag t in the sentence p, l q Indicates the length of sentence q, l p represents the length of statement p, Represents the multivector corresponding to the content at length i of sentence q, It represents the multivector corresponding to the content of sentence p at length j, and T represents the transposition symbol.
[0050] As an exemplary explanation, the dense embedding vector is called Dense embedding in English, the tag of the tag t is called token in English, and the multi-vector is called Multi vector in English.
[0051] In an optional embodiment, the dense embedding vector Weight and multi-vector The expressions include:
[0052]
[0053] In the formula, E q represents the embedding vector corresponding to the sentence to be translated q, norm(·) represents the normalization function, Maxpooling(·) represents the maximum pooling function; ReLU(·) represents the ramp function, E q [t] represents the embedding vector E q The content corresponding to the mark t in W spare express The corresponding Gaussian initialized matrix is, express The corresponding Gaussian-initialized matrix.
[0054] As an example, the dense embedding vector Weight and multi-vector The dense embedding vector can be obtained by changing q to p in the expression of Weight and multi-vector expression.
[0055] In an optional embodiment, when the translation example is input into the large language model, the translation example is used as a prompt word, and a preset prompt word template is used to prompt the large language model to translate the sentence to be translated according to the translation example, so as to obtain a plurality of sentences to be selected for translation;
[0056] The candidate translation sentences are scored for translation quality to obtain a plurality of translation quality scores, the candidate translation sentences are reordered in descending order of the translation quality scores, and the first plurality of the candidate translation sentences or the candidate translation sentence with the highest translation quality score is used as the translation result of the candidate translation sentence.
[0057] As an exemplary explanation, when a large language model is used to obtain several candidate translation sentences, a fixed prompt template (prompt word template) is used to achieve this. The fixed prompt template contains various variable placeholders, which are convenient for filling in the results retrieved from the standard corpus. By filling in appropriate examples, adaptive prompts for different source texts are achieved. Figure 2 This is a schematic diagram of a prompt word template with a variable placeholder proposed in this embodiment. Figure 2 In the example, the placeholders {src-lang} and {tgt-lang} will be replaced by the target language name of a specific language, such as Chinese, English, French, etc. Similarly, the placeholders {src-demo} and {tgt-demo} will also be replaced by the retrieved translation demo.
[0058] In this optional embodiment, corresponding neural networks and prompt words can be constructed according to the needs of different fields and languages, thereby effectively reducing the investment in manpower and material resources.
[0059] In an optional embodiment, when the translation quality of the candidate translation sentences is scored, the candidate translation sentences are input into a reordering model E, and the reordering model E outputs the candidate translation sentences arranged in descending order according to the translation quality scores;
[0060] The reordering model E includes a Bert series network.
[0061] In an optional embodiment, before using the reordering model E to score the translation quality of the candidate translation sentence, the reordering model E is pre-trained using a training set, and the steps include:
[0062] Using negative sampling, interference is added to the translation sentence of each translation example in the bilingual dataset to form an interfered text and generate an interfered dataset D′. The expression of the dataset D′ includes:
[0063]
[0064] s′ i ∈[0, 1]
[0065]
[0066] s′ i =1-0.2|b i |
[0067] In the formula, The translation sentence representing the i-th translation example of the bilingual dataset The corresponding perturbed text; s′ i express The corresponding translation quality score, s′ i The closer to 1, the The closer in, The corresponding translation quality score is 1; N represents the total number of translation examples in the bilingual dataset; Indicates that b i The interference function of the interference mode is also expressed as Through Add b i The interference corresponding to the interference mode is obtained, b i is the default value, and |·| represents the absolute value symbol.
[0068] As an exemplary illustration, the interference modes include: parallel text (Parallel), back translation (Back), inserting source text (Insert), spelling error (Se), repeated translation (Ret) and synonym replacement (Replace).
[0069] In an optional embodiment, when the reordering model E is pre-trained using the training set, the loss function of the reordering model E is iteratively solved. Until the loss function When the function value reaches the minimum value or the number of iterations reaches the preset number, the iteration is stopped to obtain the translated sentences arranged in descending order according to the translation quality scores;
[0070] The reranking model E and the loss function The expressions include:
[0071]
[0072] In the formula, BERT(·) represents the Bert series network, represents the input data input into the re-ranking model, represents the re-ranking model prediction The corresponding translation quality score, Sigmoid(·) represents the Sigmoid function, Linear(·) represents the linear layer of the reordering model E, and also represents the linear layer of the Bert series network, and E[0] represents After inputting model E, the first vector among all vectors output by model E; ||·|| 2 represents the L2 norm.
[0073] As an example, After inputting model E, the total number of vectors output by model E is equal to The token length.
[0074] Example 2
[0075] This embodiment is based on the machine translation method based on a large language model proposed in Embodiment 1. Figure 3 This is a second flow chart of the machine translation method based on a large language model proposed in this embodiment, as shown in FIG. Figure 3 As shown, this embodiment proposes the following specific implementation examples:
[0076] Assuming that we want to translate a certain vertical field from one language to another new language, we will set a standard corpus. Can be obtained from Retrieve standard translation examples from <d src , d tgt >, d src represents the source sentence, d tgt It represents the standard translation target sentence. Each example in <d src , d tgt >composed of.
[0077] For a given source sentence q, the text is first converted into E through the embedding layer in LLM. q Based on the embedding vector E q , the embedding forms of Dense embedding, Spare embedding, and Multi-vector are expressed as follows:
[0078] 1) Dense embedding Through the maximum pooling E q And normalize it to get
[0079] 2) Spare embedding For each token t in the source sentence q, the weight of each token can be calculated, and the expression is: Where ReLU represents the ramp function and H represents the dimension of the embedding matrix, W spare After the Gaussian initialization matrix, this method will be used to convert the original E q [t] Projected into a new dimension.
[0080] 3)Multi-vector is an extension of dense embedding that uses the entire output embedding for text representation, expressed as follows: in Consistent with the above Spareembedding, both are initialized by Gaussian.
[0081] After obtaining the E embedded based on LLM’s own embedding q Three hybrid embeddings from transformation and After that, the synchronization operation is performed on a certain example p to obtain the corresponding three hybrid embeddings and Then calculate the score s between q and p rerank , the specific form is as follows:
[0082] 1) The correlation score can be calculated by the inner product between the two.
[0083] 2) For Spare embedding retrieval, it is necessary to calculate the co-existing tokens between the two sentences and then calculate the score between the two sentences, which is expressed as follows:
[0084] Among them, the coexistence mark of two sentences is defined as q∩p.
[0085] 3) The score of Multi-vector retrieval is calculated through later interactive calculations. The expression is as follows: Among them l q and l pIt represents the length of text q and example p.
[0086] The above formula can be used to obtain the different scores of the three retrieval methods for the source sentence q and a certain example p, and finally the mixed retrieval score of the two can be obtained, which is expressed as follows:
[0087] s rank =α 1 ×s dense +α 2 ×s spare +α 3 ×s multi
[0088] Here α 1 ,α 2 , α 3 are three hyperparameters used to adjust the weights of the three retrieval modules. For a given source sentence q, the hybrid retrieval example framework first selects the source sentence based on q and d. src The mixed correlation score s rank Retrieve from the corpus <d src , d tgt >. Regulations Here h (·) represents the retrieval function based on the hybrid relevance score.
[0089] Since the output of LLM is based on probability sampling, different outputs may have certain semantic deviations, thus affecting the final translation quality. To solve this problem, LLM is deployed to generate multiple output candidates of the target language, and a smaller neural network model is trained at low cost through self-supervised negative sampling to reorder these outputs and obtain the optimal translation result. This method effectively improves the accuracy of translation while reducing costs. The following is a detailed introduction to this method:
[0090] 1) Negative sampling: Figure 4 This is a schematic diagram of the text after interference proposed in this embodiment, such as Figure 4 As shown, assuming that the corpus in They represent the i-th source sentence and the text of the target language respectively. Negative sampling is used to guide corpus generation The source data text can be disturbed by the interference method set A For example, convert to parallel text (Parallel), back translation (Back), insert source text (Insert), spelling errors (Se), repeated translation (Ret), synonym replacement (Replace). In this way, the corresponding text can be obtained. in It represents the text after interference, si ′ represents the score after interference. Definition of original text The quality score of is 1. Assume that set B does not contain any interference method in A, which means that only the original text needs to be copied to If B contains all possible combinations of interference methods in A, the degraded text can be obtained. and i ′, their expressions are as follows:
[0091]
[0092] s i ′=1-0.2|b i |
[0093] here It means that there is b i The interference function of the combination, |b i | indicates b i In this way, a large amount of training data can be obtained to train the Rerank sorter in a self-supervised manner.
[0094] Figure 5 This is a schematic diagram of the reordering model training process proposed in this embodiment, such as Figure 5 As shown, the Bert series network is used as the benchmark of the Rerank network (reranking model E). Given the degraded text and the quality score s i ′, is the prediction quality assessment score of the model As close as possible i ′. The Rerank reordering network maps the output code to a 1-D floating point number through a linear layer, and uses the Sigmoid function to normalize the output to between 0 and 1, thereby calculating the quality assessment score. In order to optimize the Rerank reordering network, the mean square error is used as its objective function. All the above modeling expressions are as follows:
[0095]
[0096] Next, we will introduce how the present invention can effectively improve the translation performance of LLM in vertical fields. The present invention constructs an adaptive few-sample prompt framework to search the database for bilingual translation examples that best match the current input. At the same time, the diverse outputs of LLM are sorted, and the results with the highest scores are given priority. This method can be widely used in multiple languages and different vertical fields, effectively improving the accuracy and efficiency of translation.
[0097] This method is applicable to translation tasks using various types of LLMs in different vertical fields. The specific implementation details depend on the user's basic equipment. The adaptive few-shot prompt framework requires the user to prepare sufficient vertical bilingual datasets in advance. The specific requirements are as follows:
[0098] 1) The dataset can contain texts in any language and field, and each text must be accompanied by a standard target language translation text. The dataset must undergo data cleaning operations to ensure its high quality. 2) After obtaining the bilingual dataset, the dataset needs to be stored using a mixed example retrieval framework for subsequent retrieval. 3) In addition, the bilingual dataset needs to be negatively sampled and used to train the Rerank network. Through these steps, this method can effectively improve translation performance in multiple languages and vertical fields.
[0099] To sum up, the primary task is to build high-quality bilingual datasets in vertical fields. Figure 6 This is a schematic diagram of a third process flow of the machine translation method based on a large language model proposed in this embodiment, as shown in FIG. Figure 6 As shown in the figure, after the dataset is constructed, the following work needs to be done with the dataset: 1) Construct a retrieval matrix based on a hybrid example retrieval framework to quickly extract the most relevant examples for the current translation task, 2) Use a bilingual dataset for negative sampling to provide the necessary data support for the training of the Rerank network. 3) Finally, the text to be translated is also passed through the hybrid example retrieval framework to retrieve the most similar examples from the database, and the prompt words are constructed and sent to the LLM. The output of the LLM is then sorted through the Rerank network to finally obtain the best translation result.
[0100] Compared with the prior art, the present invention constructs a hybrid retrieval method based on three methods: Dense embedding, Sparse Embedding and Multi-vector, which can extract the top k examples most relevant to the current translation sentence from the standard data set in the vertical field, thereby reducing the reliance on experts to construct special prompt words. In view of the diverse characteristics of LLM output, a neural network Rerank is trained to sort the results of LLM sampling output, and the best translation result is selected at a relatively low cost. Due to the high cost of manually annotated data sets, a self-supervised training method is adopted to perform negative sampling by perturbing the standard text, and train the Rerank network at a lower cost.
[0101] Example 3
[0102] This embodiment proposes a machine translation system based on a large language model, which is used to implement a machine translation method based on a large language model proposed in Embodiment 1.
[0103] The machine translation system based on the large language model comprises:
[0104] A database acquisition module is used to acquire a bilingual data set containing a plurality of translation examples, wherein each translation example includes a source sentence and a translation sentence corresponding to the source sentence;
[0105] A module for obtaining sentences to be translated, used for obtaining sentences to be translated;
[0106] An embedding vector generation module, used to convert the to-be-translated sentence and the source sentence in the translation example into embedding vectors respectively using a large language model;
[0107] A correlation score calculation module, used to calculate the correlation score between the embedding vector corresponding to the sentence to be translated and the embedding vector corresponding to the source sentence;
[0108] An example acquisition module is used to select source sentences and translation sentences with the first several largest correlation scores or correlation scores with values greater than a preset threshold as translation examples;
[0109] The translation module is used to input the translation example into the large language model, so that the large language model translates the sentence to be translated according to the translation example.
[0110] This embodiment proposes a computer device, including a memory and a processor, wherein the memory stores computer-readable instructions, and when the computer-readable instructions are executed by the processor, the processor executes the steps of the machine translation method based on a large language model described in Example 1.
[0111] It can be understood that the machine translation system and computer device based on the large language model of this embodiment improve the method of Example 1. The options in the above-mentioned Example 1 are also applicable to this embodiment, so they will not be repeated here.
[0112] The same or similar reference numerals correspond to the same or similar components;
[0113] The terms used to describe the positional relationship in the drawings are only used for illustrative purposes and should not be construed as limiting the present embodiment;
[0114] Obviously, the above embodiments of the present invention are merely examples for clearly illustrating the present invention, and are not intended to limit the embodiments of the present invention. For those skilled in the art, other different forms of changes or modifications can be made based on the above description. It is not necessary and impossible to list all the embodiments here. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included in the protection scope of the claims of the present invention.
Claims
1. A machine translation method based on a large language model, characterized in that: The following steps are involved: Obtain a bilingual data set including a plurality of translation examples, wherein each translation example includes a source sentence and a translation sentence corresponding to the source sentence; Get the sentence to be translated; Using a large language model, the sentence to be translated and the source sentence in the translation example are respectively converted into embedding vectors; Calculating a correlation score between the embedding vector corresponding to the sentence to be translated and the embedding vector corresponding to the source sentence; Selecting the source sentences and their translated sentences with the first several largest correlation scores or correlation scores with values greater than a preset threshold as translation examples; The translation example is input into the large language model, so that the large language model translates the sentence to be translated according to the translation example.
2. The machine translation method based on a large language model according to claim 1, characterized in that: When using a large language model to convert the sentence to be translated and the source sentence in the translation example into embedding vectors respectively, the sentence to be translated and the source sentence in the translation example are respectively input into the large language model, and the embedding layer of the large language model converts the sentence to be translated and the source sentence in the translation example into embedding vectors respectively.
3. The machine translation method based on a large language model according to claim 2, characterized in that: When calculating the correlation score between the embedding vector corresponding to the sentence to be translated and the embedding vector corresponding to the source sentence, the expression of the correlation score includes: S rank =α1×S dense +α2×S spare +α3×S multi In the formula, α1 represents S dense The weight of S spare The weight of S multi The weight of q represents the sentence to be translated, and p represents any source sentence in the bilingual dataset. represents the dense embedding vector corresponding to sentence q, represents the dense embedding vector corresponding to sentence p, q∩p represents the set of all co-occurring tokens of sentence q and sentence p, t represents any element in q∩p, represents the weight corresponding to the tag t in the sentence q, represents the weight corresponding to the tag t in the sentence p, l q Indicates the length of sentence q, l p represents the length of statement p, Represents the multivector corresponding to the content at length i of sentence q, It represents the multivector corresponding to the content of sentence p at length j, and T represents the transposition symbol.
4. The machine translation method based on a large language model according to claim 2, characterized in that: The dense embedding vector Weight and multi-vector The expressions include: In the formula, E q represents the embedding vector corresponding to the sentence to be translated q, norm(·) represents the normalization function, Maxpooling(·) represents the maximum pooling function; ReLU(·) represents the ramp function, E q [t] represents the embedding vector E q The content corresponding to the mark t in W spare express The corresponding Gaussian initialized matrix is, express The corresponding Gaussian-initialized matrix.
5. The machine translation method based on a large language model according to any one of claims 1 to 4, characterized in that: When the translation example is input into the large language model, the translation example is used as a prompt word, and a preset prompt word template is used to prompt the large language model to translate the sentence to be translated according to the translation example, so as to obtain a plurality of sentences to be selected for translation; The candidate translation sentences are scored for translation quality to obtain a plurality of translation quality scores, the candidate translation sentences are reordered in descending order of the translation quality scores, and the first plurality of the candidate translation sentences or the candidate translation sentence with the highest translation quality score is used as the translation result of the candidate translation sentence.
6. The machine translation method based on a large language model according to claim 5, characterized in that: When performing translation quality scoring on the candidate translation sentences, the candidate translation sentences are input into a reordering model E, and the reordering model E outputs the candidate translation sentences arranged in descending order according to the translation quality scores; The reordering model E includes a Bert series network.
7. The machine translation method based on a large language model according to claim 6, characterized in that: Before using the reordering model E to score the translation quality of the candidate translation sentence, the reordering model E is pre-trained using a training set, the steps of which include: Using negative sampling, interference is added to the translation sentence of each translation example in the bilingual dataset to form an interfered text, and a interfered dataset D is generated. ′ , the data set D ′ The expressions include: s i ′ ∈[0,1] s i ′ =1-0.2|b i | In the formula, The translation sentence representing the i-th translation example of the bilingual dataset The corresponding text after interference; s i ′ express The corresponding translation quality score, s i ′ The closer to 1, the The closer in, The corresponding translation quality score is 1; N represents the total number of translation examples in the bilingual dataset; Indicates that b i The interference function of the interference mode is also expressed as Through Add b i The interference corresponding to the interference mode is obtained, b i is the default value, and |·| represents the absolute value symbol.
8. The machine translation method based on a large language model according to claim 7, characterized in that: When the reordering model E is pre-trained using the training set, the loss function of the reordering model E is iteratively solved Until the loss function When the function value reaches the minimum value or the number of iterations reaches the preset number, the iteration is stopped to obtain the translated sentences arranged in descending order according to the translation quality scores; The reranking model E and the loss function The expressions include: In the formula, BERT(·) represents the Bert series network, represents the input data input into the re-ranking model, represents the re-ranking model prediction The corresponding translation quality score, Sigmoid(·) represents the Sigmoid function, Linear(·) represents the linear layer of the reordering model E, and also represents the linear layer of the Bert series network, and E[0] represents After inputting model E, the first vector among all vectors output by model E; ‖·‖2 represents the L2 norm.
9. A machine translation system based on a large language model, used to implement the machine translation method based on a large language model according to any one of claims 1 to 8, characterized in that: include: A database acquisition module is used to acquire a bilingual data set containing a plurality of translation examples, wherein each translation example includes a source sentence and a translation sentence corresponding to the source sentence; A module for obtaining sentences to be translated, used for obtaining sentences to be translated; An embedding vector generation module, used to convert the to-be-translated sentence and the source sentence in the translation example into embedding vectors respectively using a large language model; A correlation score calculation module, used to calculate the correlation score between the embedding vector corresponding to the sentence to be translated and the embedding vector corresponding to the source sentence; An example acquisition module is used to select source sentences and translation sentences with the first several largest correlation scores or correlation scores with values greater than a preset threshold as translation examples; The translation module is used to input the translation example into the large language model, so that the large language model translates the sentence to be translated according to the translation example.
10. A computer device comprising a memory and a processor, wherein the memory stores computer-readable instructions, characterized in that: When the computer-readable instructions are executed by the processor, the processor executes the steps of the large language model-based machine translation method according to any one of claims 1 to 8.
Citation Information
Patent Citations
Machine translation result scoring method and device
CN112464676A
Large model machine translation method based on RAG
CN117993396A
Translation method and device for machine translation large language model based on example perception
CN118468899A