Machine translation method and system based on large language model
By acquiring translation examples from bilingual datasets, and optimizing the translation process using large language models and reordering models, the problem of poor translation performance of large language models in vertical domains is solved, achieving efficient and accurate translation results.
Patent Information
- Application Number
- CN202411664912.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-20
- Publication Date
- 2025-11-25
- Estimated Expiration
- 2044-11-20
AI Technical Summary
Existing large language models suffer from poor translation performance in vertical domain machine translation tasks, especially when dealing with unfamiliar proper nouns or technical terms, which may generate incorrect translated sentences. Furthermore, the diversity of outputs prevents them from providing optimal translation results.
By obtaining translation examples from bilingual datasets, the large language model is used to transform the sentences to be translated and the source sentences into embedding vectors, calculate the relevance scores, select the translation examples with the highest relevance as prompt words, input them into the large language model for translation, and use a re-ranking model to sort the diverse outputs of the LLM to optimize the translation results.
It improves translation quality in vertical fields, reduces manpower and material resources, and ensures the accuracy and consistency of translation results.
Smart Images

Figure CN119721064B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of natural language processing, and more specifically, to a machine translation method and system based on a large language model. Background Technology
[0002] With the development of artificial intelligence, Large Language Models (LLMs) with context learning capabilities have gradually come into focus. Along with the rapid development of LLMs, their performance in traditional natural language tasks such as machine translation has attracted considerable attention. Recent research has shown that LLMs have demonstrated superior performance in machine translation and significantly reduced the consumption of human and material resources, which is noteworthy.
[0003] However, LLM still has certain limitations in natural language processing tasks, especially translation. Although LLM can translate sentences in the target language well after training on extensive datasets, it performs poorly in certain vertical domain translation tasks. For translation tasks in specific vertical domains, LLM may encounter proper nouns or technical terms that were not encountered during training. Without appropriate cue words to convey this information to the LLM, it may make incorrect judgments and generate poor-quality translations. Furthermore, the output of an LLM is essentially a probabilistic model, and the prediction of the next token can be subject to various interferences, resulting in the same sentence being processed by the same LLM producing multiple different outputs. Therefore, the diverse outputs of an LLM may not provide optimal translation results.
[0004] In summary, existing machine translation methods suffer from poor translation quality. Summary of the Invention
[0005] To overcome the shortcomings of the existing technology in terms of poor translation results, this invention provides a machine translation method and system based on a large language model with excellent translation performance.
[0006] To solve the above-mentioned technical problems, the technical solution of the present invention is as follows:
[0007] Obtain a bilingual dataset containing several translation examples, where each translation example includes a source sentence and the corresponding translation sentence;
[0008] Get the sentence to be translated;
[0009] 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.
[0010] Calculate the relevance score between the embedding vector of the sentence to be translated and the embedding vector of the source sentence;
[0011] Select the top few relevance scores with the largest values or relevance scores greater than a preset threshold, along with their translated versions, 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 in accordance with the translation example.
[0013] This invention also proposes a machine translation system based on a large language model to implement the aforementioned machine translation method based on a large language model, the system comprising:
[0014] The database acquisition module is used to acquire a bilingual dataset containing several translation examples, wherein each translation example includes a source sentence and the corresponding translation sentence;
[0015] The module for obtaining sentences to be translated is used to obtain sentences to be translated.
[0016] The embedding vector generation module is used to convert the sentence to be translated and the source sentence in the translation example into embedding vectors using a large language model.
[0017] The relevance score calculation module is used to calculate the relevance score between the embedding vector of the sentence to be translated and the embedding vector of the source sentence.
[0018] The example acquisition module is used to select the source sentences and their translation sentences with the highest relevance scores or relevance scores 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 can translate the sentence to be translated in accordance with 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, which, when executed by the processor, cause the processor to perform the steps of the machine translation method based on the large language model described above.
[0021] Compared with the prior art, the beneficial effects of the technical solution of the present invention are:
[0022] The large language model is used to convert the sentence to be translated and the source sentences in the translation examples into embedding vectors. The relevance scores between the embedding vectors of the sentence to be translated and the embedding vectors of the source sentences are used to select the source sentences and their translations with the highest relevance scores or relevance scores greater than a preset threshold as translation examples. The large language model then translates the sentence to be translated in accordance with the translation examples. The translation examples and the sentence to be translated have a high degree of overlap in information, thereby resulting in excellent translation quality. Attached Figure Description
[0023] Figure 1 This is a schematic diagram of the first process of the machine translation method based on a large language model proposed in Example 1;
[0024] Figure 2 This is a schematic diagram of the prompt word template containing variable placeholders proposed in Example 1;
[0025] Figure 3 This is a schematic diagram of the second process of the machine translation method based on a large language model proposed in Example 2;
[0026] Figure 4 This is a schematic diagram of the text after interference as proposed in Example 2;
[0027] Figure 5 This is a schematic diagram of the training process for the reordering model proposed in Example 2;
[0028] Figure 6 This is a schematic diagram of the third process of the machine translation method based on a large language model proposed in Example 2. Detailed Implementation
[0029] The accompanying drawings are for illustrative purposes only and should not be construed as limiting the scope of this embodiment.
[0030] To better illustrate this embodiment, some parts in the accompanying drawings may be omitted, enlarged, or reduced, and do not represent the actual product dimensions;
[0031] It will be understood by those skilled in the art that certain well-known structures and their descriptions may be omitted in the accompanying drawings.
[0032] The technical solution of the present invention will be further described below with reference to the accompanying drawings and embodiments.
[0033] Example 1
[0034] This embodiment proposes a machine translation method based on a large language model. Figure 1 This is a schematic diagram of the first process of the machine translation method based on a large language model in this embodiment;
[0035] The machine translation method based on a large language model proposed in this embodiment includes the following steps:
[0036] S1: Obtain a bilingual dataset containing several translation examples, wherein each translation example includes a source statement and the corresponding translation statement;
[0037] S2: Get the sentence to be translated;
[0038] S3: Use 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 of the sentence to be translated and the embedding vector of the source sentence;
[0040] S5: Select the source sentences and their translations with the highest relevance scores or relevance scores greater than a preset threshold as translation examples.
[0041] S6: Input the translation example into the large language model, so that the large language model translates the sentence to be translated in accordance with the translation example.
[0042] In the specific implementation process, a large language model is used to convert the sentence to be translated and the source sentences in the translation examples into embedding vectors respectively. The relevance scores between the embedding vectors of the sentence to be translated and the embedding vectors of the source sentences are used to select the source sentences and their translations with the highest relevance scores or relevance scores greater than a preset threshold as translation examples. The large language model then translates the sentence to be translated in accordance with the translation examples. The translation examples and the sentence to be translated have a high degree of overlap in information, thereby resulting in excellent translation quality.
[0043] In an optional embodiment, when using a large language model to convert the statement to be translated and the source statement in the translation example into embedding vectors respectively, the statement to be translated and the source statement in the translation example are respectively input into the large language model, and the embedding layer of the large language model converts the statement to be translated and the source statement in the translation example into embedding vectors respectively.
[0044] In an optional embodiment, when calculating the relevance score between the embedding vector corresponding to the statement to be translated and the embedding vector corresponding to the source statement, the expression for the relevance score includes:
[0045] S rank =α1×S dense +α2×S spare +α3×S multi
[0046]
[0047]
[0048]
[0049] In the formula, α1 represents S dense The weights, α2 represents S spare The weights, α3 represents S multi The weights are denoted by q, where q represents the sentence to be translated, and p represents any source sentence in the bilingual dataset. This represents the dense embedding vector corresponding to statement q. Let q represent the dense embedding vector corresponding to statement p, q∩p represent the set of all coexisting tags of statements q and p, and t represent any element in q∩p. This indicates the weight corresponding to the marker t in statement q. The weight corresponding to the label t in statement p, l q The length of statement q is represented by l. p Indicates the length of statement p. This represents the multivector corresponding to the content at position i of length q in statement q. This represents the multivector corresponding to the content at length j in statement p, where T represents the transpose symbol.
[0050] As an example, the full English name of the dense embedding vector is Dense embedding, the full English name of the token t is token, and the full English name of the multi vector is Multi vector.
[0051] In an alternative embodiment, the dense embedding vector Weight and multi-vector The expressions include:
[0052]
[0053] In the formula, E q This represents the embedding vector corresponding to the statement q to be translated, where norm(·) represents the normalization function, Maxpooling(·) represents the max pooling function, ReLU(·) represents the ramp function, and E q [t] represents the embedding vector E q The content corresponding to the marker t in the middle, W spare express The corresponding Gaussian-initialized matrix, express The corresponding Gaussian-initialized matrix.
[0054] As an example, the dense embedding vector Weight and multi-vector Replacing q with p in the expression will yield the dense embedding vector. Weight and multi-vector The 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 the large language model is prompted to translate the sentence to be translated in accordance with the translation example through a preset prompt word template, so as to obtain a number of sentences to be translated.
[0056] The candidate translation sentences are scored for translation quality, resulting in several translation quality scores. The candidate translation sentences are then reordered in descending order of translation quality scores, and the top few candidate translation sentences or the candidate translation sentences with the highest translation quality scores are taken as the translation results of the candidate translation sentences.
[0057] As an example, when obtaining several candidate translation sentences using a large language model, a fixed prompt template (prompt word template) is used. This fixed prompt template contains various variable placeholders, which are convenient for filling in results retrieved from a standard corpus. By filling in appropriate examples, adaptive prompts for different source texts are achieved. Figure 2 This is a schematic diagram of the prompt word template containing variable placeholders proposed in this embodiment. Figure 2 In this context, the placeholders {src-lang} and {tgt-lang} will be replaced with the target language name in the actual application, such as Chinese, English, and French. Similarly, the placeholders {src-demo} and {tgt-demo} will be replaced with the retrieved translation demos.
[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 of human and material resources.
[0059] In an optional embodiment, when scoring the translation quality of the candidate translation statements, the candidate translation statements are input into a reordering model E, and the reordering model E outputs the candidate translation statements arranged in descending order of translation quality scores;
[0060] The reordering model E includes the Bert family of networks.
[0061] In an optional embodiment, before using the re-ranking model E to score the translation quality of the candidate translation sentences, the re-ranking model E is pre-trained using a training set, the steps of which include:
[0062] Using negative sampling, interference is added to the translated sentences of each translation example in the bilingual dataset to form the interfered text, generating the interfered dataset D′. The expression of dataset D′ includes:
[0063]
[0064] s′ i ∈[0,1]
[0065]
[0066] s′ i =1-0.2|b i |
[0067] In the formula, This represents the translated sentence of the i-th translation example in the bilingual dataset. The corresponding text after interference; s′ i express The corresponding translation quality score, s′ i The closer to 1, the better. The closer in, The corresponding translation quality score is 1; N represents the total number of translation examples in the bilingual dataset; Indicates having b i The interference function for each type of interference also represents... Through the Add b i The interference corresponding to each interference method is obtained, b i This is the default value, and |·| represents the absolute value symbol.
[0068] As an example, the interference methods include: parallel text, back translation, inserting source text, spelling errors, repeated translation, and synonym replacement.
[0069] In an optional embodiment, when pre-training the reordering model E 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 stops, and the translated sentences are obtained in descending order of translation quality score;
[0070] The reordering model E and the loss function The expressions include:
[0071]
[0072] In the formula, BERT(·) represents the BERT family of networks. This represents the input data for the reordering model. This indicates that the reordering model predicts... 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, E[0] represents the... The first vector among all vectors output by model E after inputting 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 length of the token.
[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 schematic diagram of the second process of the machine translation method based on a large language model proposed in this embodiment, as shown below. Figure 3 As shown, this embodiment presents the following specific implementation examples:
[0076] Suppose we want to perform translation work from one language to another in a specific vertical field, we would set up a standard corpus. From Retrieve standard translation examples <d src d tgt >,d src This refers to the source statement, d tgt This represents the standard target translation statement. Each example in the example is by <d src d tgt Composed of >
[0077] For a given source statement q, the text will first be converted into E through the embedding layer in the LLM. q Based on embedding vector E q The embedding forms of Dense embedding, Spare embedding, and Multi-vector are expressed as follows:
[0078] 1) Dense embedding Through maximum pooling E q And by normalizing it, we finally obtained
[0079] 2) Spare embedding For each token t in the source statement q, the weight of each token can be calculated using the following expression: Where ReLU represents the ramp function and H represents the dimension of the embedding matrix, W spare The matrix initialized by Gaussians will be used in this way to convert the original E... q [t] is projected onto a new dimension.
[0080] 3) Multi-vector It is an extension of dense embedding for text representation that utilizes the entire output embedding, as shown in the following expression: in Like the Spareembedding mentioned above, it is initialized using Gaussian initialization.
[0081] After obtaining the E based on the LLM's own embedding... q Three hybrid embeddings derived from the transformation and Then, a synchronization operation will be performed on a specific 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 using the inner product between the two.
[0083] 2) For Spare embedding retrieval, it is necessary to calculate the coexisting tokens between the two sentences and then calculate the score between the two sentences, as shown below:
[0084] The coexistence of two sentences is defined as q∩p.
[0085] 3) The score for Multi-vector retrieval is calculated through subsequent interactive computation, as shown in the following expression: Among them l q and l p This represents the length of the text q and the example p.
[0086] The above formula yields different scores for three retrieval methods for the source statement q and a specific example p. Finally, a combined retrieval score for both can be obtained, expressed as follows:
[0087] s rank =α1×s dense +α2×s spare +α3×s multi
[0088] Here, α1, α2, and α3 are three hyperparameters used to adjust the weights of the three retrieval modules. For a given source statement q, the hybrid retrieval example framework first adjusts the weights based on q and d. src Mixed correlation score s rank Retrieved from the corpus <d src d tgt >. Regulations Here f h (·) represents a retrieval function based on mixed relevance scores.
[0089] Since LLM outputs are based on probability sampling, different outputs may contain semantic biases, affecting the final translation quality. To address this issue, this method forces the deployment of LLM to generate multiple output candidates for the target language. Then, through self-supervised negative sampling, a small neural network model is trained at low cost to reorder these outputs, thereby obtaining the optimal translation result. This approach effectively improves translation accuracy while reducing costs. The following is a detailed description of the method:
[0090] 1) Negative sampling: Figure 4 This is a schematic diagram of the text after interference as proposed in this embodiment, as shown below. Figure 4 As shown, assuming the corpus in These represent the i-th source statement and the target language text, respectively. Negative sampling should be used to guide corpus generation. The source data text can be interfered with using a set of interference methods A. For example, it can convert to parallel text, back translation, insert source text, correct spelling errors, repeat translation, and replace synonyms. This allows you to obtain the corresponding text. in This refers to the text after interference, s i ′ represents the score after interference. Define the original text. The quality score is 1. Assuming set B does not contain any of the perturbation methods from A, this means that simply copying the original text to... In the context of text processing, if B contains all possible combinations of the interference methods in A, then the degraded text can be obtained. and s i Their way of expressing it is as follows:
[0091]
[0092] s i ′=1-0.2|b i |
[0093] here It means having b i Interference function of combination method, |b i | represents b i The number of perturbation methods. This method can obtain a large amount of trainable data, allowing for the self-supervised training of the Rerank sorter.
[0094] Figure 5 This is a schematic diagram of the training process of the reordering model proposed in this embodiment, as shown below. Figure 5 As shown, the Bert family of networks was used as the baseline for the Rerank network (reordering model E). Given degraded text... and quality fraction s i ′ is the model's prediction quality assessment score. As close to s as possible i The Rerank network maps the output encoding to 1-D floating-point numbers through linear layers and uses the sigmoid function to normalize the output to between 0 and 1, thereby calculating the quality assessment score. To optimize the Rerank network, mean squared error is used as its objective function. All the above modeling expressions are as follows:
[0095]
[0096] The following section describes how this invention efficiently improves the translation performance of LLM in vertical domains. This invention constructs an adaptive few-shot suggestion framework to search a database for the bilingual translation example that best matches the current input. Simultaneously, it sorts the diverse outputs of the LLM, prioritizing the results with the highest scores. This method can be widely applied to multiple languages and different vertical domains, effectively improving the accuracy and efficiency of translation.
[0097] This method is applicable to translation tasks using various types of LLMs across different vertical domains. Specific implementation details depend on the user's available equipment. The adaptive few-shot hinting framework requires the user to prepare sufficient bilingual datasets for the vertical domain beforehand, with the following specific requirements:
[0098] 1) The dataset can contain text in any language and domain, and each text must be accompanied by a standard target language translation. The dataset must undergo data cleaning to ensure its high quality. 2) After obtaining the bilingual dataset, it needs to be stored using a hybrid example retrieval framework for subsequent retrieval. 3) Furthermore, the bilingual dataset needs to be negatively sampled, and these negatively sampled datasets are used to train the Rerank network. Through these steps, this method can efficiently improve translation performance across multiple languages and vertical domains.
[0099] In summary, the primary task is to build high-quality bilingual datasets for vertical domains. Figure 6 This is a schematic diagram of the third process of the machine translation method based on a large language model proposed in this embodiment, as shown below. Figure 6 As shown, after constructing the dataset, the following steps need to be performed: 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) Perform negative sampling using a bilingual dataset to provide necessary data support for training the Rerank network; 3) Finally, the text to be translated is also processed through the hybrid example retrieval framework to retrieve the most similar examples from the database. After constructing the prompt words, they are fed into the LLM. The LLM output is then processed by the Rerank network for sorting, ultimately yielding the best translation result.
[0100] Compared with existing technologies, this invention constructs a hybrid retrieval method based on three approaches: Dense embedding, Sparse embedding, and Multi-vector. This method can extract the top k most relevant examples to the current translation sentence from standard datasets in a vertical domain, thereby reducing reliance on expert-constructed prompts. To address the diverse output characteristics of LLM (Limited Language Modeling), a Rerank neural network is trained to rank the LLM sampling outputs, selecting the best translation result at a lower cost. Since manually annotated datasets are expensive, a self-supervised training method is employed, using perturbation of the standard text for negative sampling to 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 to implement the machine translation method based on a large language model proposed in Embodiment 1.
[0103] The machine translation system based on a large language model includes:
[0104] The database acquisition module is used to acquire a bilingual dataset containing several translation examples, wherein each translation example includes a source sentence and the corresponding translation sentence;
[0105] The module for obtaining sentences to be translated is used to obtain sentences to be translated.
[0106] The embedding vector generation module is used to convert the sentence to be translated and the source sentence in the translation example into embedding vectors using a large language model.
[0107] The relevance score calculation module is used to calculate the relevance score between the embedding vector of the sentence to be translated and the embedding vector of the source sentence.
[0108] The example acquisition module is used to select the source sentences and their translation sentences with the highest relevance scores or relevance scores 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 can translate the sentence to be translated in accordance with the translation example.
[0110] This embodiment proposes a computer device, including a memory and a processor. The memory stores computer-readable instructions, which, when executed by the processor, cause the processor to perform the steps of the machine translation method based on a large language model as described in Embodiment 1.
[0111] It is understood that the machine translation system and computer device based on the large language model in this embodiment improves the method of embodiment 1. The options in embodiment 1 are also applicable to this embodiment, so they will not be described again here.
[0112] The same or similar labels correspond to the same or similar parts;
[0113] The terms used to describe positional relationships in the accompanying drawings are for illustrative purposes only and should not be construed as limiting the scope of this 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 implementation of the present invention. Those skilled in the art will recognize that other variations or modifications can be made based on the above description. It is neither necessary nor possible to exhaustively describe all embodiments here. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the present invention should be included within the scope of protection of the claims of the present invention.
Claims
1. A machine translation method based on a large language model, characterized in that, Includes the following steps: Obtain a bilingual dataset containing several translation examples, where each translation example includes a source sentence and the corresponding translation sentence; Get the sentence to be translated; 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. Calculate the relevance score between the embedding vector of the sentence to be translated and the embedding vector of the source sentence; Select the top few relevance scores with the largest values or relevance scores greater than a preset threshold, along with their translated versions, 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 in accordance with the translation example; When the translation example is input into the large language model, the translation example is used as a prompt word. The large language model is prompted to translate the sentence to be translated in accordance with the translation example through a preset prompt word template, so as to obtain a number of sentences to be translated. The candidate translation sentences are scored for translation quality, resulting in several translation quality scores. The candidate translation sentences are then reordered in descending order of translation quality scores, and the top few candidate translation sentences or the candidate translation sentences with the highest translation quality scores are taken as the translation results of the candidate translation sentences. When scoring the translation quality of the candidate translation sentences, the candidate translation sentences are input into the re-ranking model. The reordering model The output lists the candidate translation sentences in descending order of translation quality score. The reordering model Including the Bert series of networks; Using the aforementioned reordering model Before scoring the translation quality of the candidate translation sentences, the re-ranking model is tested using the training set. Pre-training involves the following steps: Using negative sampling, interference is added to the translated sentences of each translation example in the bilingual dataset to form the perturbed text, thus generating the perturbed dataset. The dataset The expressions include: In the formula, The first character of the bilingual dataset represents the first character of the bilingual dataset. Translation example sentences The corresponding text after interference; express The corresponding translation quality score, The closer to 1, the better. The closer ,in, The corresponding translation quality score is 1; This represents the total number of translation examples in the bilingual dataset; Indicates having The interference function for each type of interference also represents... Through the Add to The interference corresponding to each interference method is obtained. As a preset value, Represents the absolute value symbol.
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, 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 relevance score between the embedding vector of the sentence to be translated and the embedding vector of the source sentence, the expression for the relevance score includes: In the formula, express The weight, express The weight, express The weight, This refers to the statement to be translated. Represents any source statement in the bilingual dataset. Statement The corresponding dense embedding vector, Statement The corresponding dense embedding vector, Indicates by statement and statements The set consisting of all coexisting tags, express any element in, Statement The mark in The corresponding weights Statement The mark in The corresponding weights Statement Length, Statement Length, Statement The length is The content at that location corresponds to multiple vectors. Statement The length is The content at that location corresponds to multiple vectors. This represents the transpose symbol.
4. The machine translation method based on a large language model according to claim 3, characterized in that, The dense embedding vector Weight and multi-vector The expressions include: In the formula, Indicates the sentence to be translated. The corresponding embedding vector, Represents the normalization function. Represents the max pooling function; Represents the ramp function. Represents the embedding vector Middle Mark The corresponding content, express The corresponding Gaussian-initialized matrix, express The corresponding Gaussian-initialized matrix.
5. The machine translation method based on a large language model according to claim 1, characterized in that, The reordering model is trained using the training set. During pre-training, the reordering model is solved iteratively. loss function until the loss function When the function value reaches the minimum value or the number of iterations reaches the preset number, the iteration stops, and the translated sentences are obtained in descending order of translation quality score; The reordering model and the loss function The expressions include: In the formula, This indicates the Bert series of networks. This represents the input data for the reordering model. This indicates that the reordering model predicts... The corresponding translation quality score, express function, Reordering model The linear layer, also representing the linear layer of the Bert series networks, Indicates will Input Model After that, the model The first vector among all output vectors; This represents the L2 norm.
6. A machine translation system based on a large language model, used to implement the machine translation method based on a large language model as described in any one of claims 1 to 5, characterized in that, include: The database acquisition module is used to acquire a bilingual dataset containing several translation examples, wherein each translation example includes a source sentence and the corresponding translation sentence; The module for obtaining sentences to be translated is used to obtain sentences to be translated. The embedding vector generation module is used to convert the sentence to be translated and the source sentence in the translation example into embedding vectors using a large language model. The relevance score calculation module is used to calculate the relevance score between the embedding vector of the sentence to be translated and the embedding vector of the source sentence. The example acquisition module is used to select the source sentences and their translation sentences with the highest relevance scores or relevance scores 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 can translate the sentence to be translated in accordance with the translation example.
7. 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 performs the steps of the machine translation method based on a large language model as described in any one of claims 1 to 5.
Citation Information
Patent Citations
Machine translation result scoring method and device
CN112464676A
Large model machine translation method based on RAG
CN117993396A