A method for enhancing machine translation of large language models based on hint optimization

By training large language models based on hint optimization and the SVD-LoRA method, the high computing power consumption and knowledge forgetting problems of traditional fine-tuning methods are solved, and the translation performance and reasoning efficiency of the model are improved.

CN120068892BActive Publication Date: 2025-09-26HARBIN INST OF TECH
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510107860.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-01-23
Publication Date
2025-09-26
Estimated Expiration
2045-01-23

AI Technical Summary

Technical Problem

Traditional fine-tuning methods consume a lot of computing power for training large language models and may cause knowledge to be forgotten, thereby reducing model translation performance.

Method used

A prompt optimization-based method is adopted to pre-train and fine-tune the prompt decoder, combine it with the SVD-LoRA method for end-to-end training, and construct optimized machine translation prompts, using an external knowledge base to optimize the input prompts of the large language model.

Benefits of technology

It improves the translation performance of large language models, enables efficient parameter fine-tuning and optimization of input prompts, and improves the model's translation performance in different specific fields.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120068892B_ABST
    Figure CN120068892B_ABST
Patent Text Reader

Abstract

The present invention discloses a large language model machine translation enhancement method based on prompt optimization, which belongs to the field of machine translation enhancement technology. It solves the problem in the prior art that the traditional fine-tuning method for large language models is difficult to improve model performance, resulting in inaccurate model translation results; the present invention pre-trains and fine-tunes the prompt decoder through the prompt decoder to obtain the pre-trained and fine-tuned prompt decoder, and constructs a large language model based on the prompt decoder; introduces the SVD-LoRA method to perform end-to-end training on the large language model based on the prompt decoder to obtain the trained large language model; based on an external knowledge base, constructs an optimized machine translation prompt, inputs the optimized machine translation prompt into the trained large language model, and obtains a target end sentence. The present invention improves the translation performance of the large language model, can automatically optimize the prompt and shorten the input prompt length, and can be applied to fine-tune the large language model.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to a large language model machine translation enhancement method, and in particular to a large language model machine translation enhancement method based on prompt optimization, belonging to the technical field of machine translation enhancement. Background Art

[0002] Large language models (LLMs) are a current research hotspot in the field of artificial intelligence. With the advancement of deep neural network architectures and computing power, neural networks have found widespread application across various industries. LLMs have emerged due to the sequential modeling approach and parallel computing efficiency offered by the Transformer (self-attention neural machine translation system). Their large number of parameters and extensive training corpus enable them to generalize well, achieving good results even on complex downstream tasks for which they have not been trained.

[0003] However, due to the huge number of parameters in large language models, using traditional fine-tuning methods to train large language models will cause huge computing power consumption and may also lead to the problem of forgetting pre-training knowledge, thereby reducing the overall performance of the model.

[0004] In summary, a method for enhancing machine translation of large language models based on hint optimization is needed. Summary of the Invention

[0005] A brief overview of the present invention is provided below to provide a basic understanding of certain aspects of the present invention. It should be understood that this overview is not an exhaustive overview of the present invention. It is not intended to identify key or important aspects of the present invention, nor is it intended to limit the scope of the present invention. Its purpose is simply to present certain concepts in a simplified form as a prelude to the more detailed description discussed later.

[0006] In view of this, in order to solve the problem in the prior art that traditional fine-tuning methods for large language models are difficult to improve model performance, resulting in inaccurate model translation results, the present invention provides a large language model machine translation enhancement method based on prompt optimization.

[0007] The technical solution is as follows: A method for enhancing machine translation of a large language model based on prompt optimization, comprising the following steps:

[0008] S1. Pre-train and fine-tune the prompt decoder through the prompt decoder to obtain a pre-trained and fine-tuned prompt decoder, and construct a large language model based on the prompt decoder;

[0009] S2. Introduce the SVD-LoRA method to perform end-to-end training on the large language model based on the hint decoder to obtain the trained large language model;

[0010] S3. Based on the external knowledge base, construct optimized machine translation prompts, input the optimized machine translation prompts into the trained large language model, and obtain the target end sentence.

[0011] Furthermore, the step S1 specifically includes the following steps:

[0012] S11. Input the text into the prompt encoder, pre-train the prompt encoder with the help of the prompt decoder to obtain the hyperparameters of the prompt encoder and the pre-trained prompt encoder;

[0013] S12. Select input data based on the hyperparameters of the prompt encoder and fine-tune the pre-trained prompt encoder to obtain a fine-tuned prompt encoder;

[0014] In the S11, an unsupervised monolingual corpus is selected as text based on the main language of the large language model, and a prompt encoder is pre-trained. According to the text sequence of length M output by the prompt encoder, a text sequence of length N at the input end of the prompt encoder is restored by the prompt decoder. According to the effect of the prompt decoder restoring the text sequence during the pre-training process, the value of the hyperparameter M is determined so that the prompt encoder compresses the text sequence of length N to a text sequence of length M;

[0015] In S12, the hyperparameter M of the prompt encoder in the pre-training stage is initialized, and fine-tuning training is performed using the p-tuning method. During the fine-tuning process, a fine-tuning dataset of instructions for general fields and different tasks is input into the large language model, and the language is aligned with the language used in the pre-training stage of the prompt encoder. The instruction text of the data in the fine-tuning dataset is used as a continuous prompt. The input data and output data of the large language model are the source end sentences and the target end sentences of the parallel corpus, respectively. The parameters of the large language model are fixed, and the adjustable parameters are the parameters of the prompt encoder and the continuous prompt.

[0016] Furthermore, the step S2 specifically includes the following steps:

[0017] S21. Establish the SVD-LoRA method based on the LoRA method, and construct a large language model based on the prompt decoder combined with the SVD-LoRA method;

[0018] S22. Performing end-to-end training based on prompt optimization on the large language model based on the prompt decoder combined with the SVD-LoRA method to obtain a trained large language model;

[0019] In S21, the process of the LoRA method is expressed as follows:

[0020]

[0021] in, is the weight before the large language model starts training, Additional weight for LoRA bypass, is a constant, based on With the current layer The scaling ratio is obtained, is the current layer;

[0022] exist 、 The process of the LoRA method at time 0 is expressed as:

[0023]

[0024] in, is the first low-rank matrix, is the second low-rank matrix;

[0025] The process of SVD-LoRA method is to use the current layer SVD decomposition results For the first low-rank matrix and the second low-rank matrix Initialize;

[0026] The process of the SVD-LoRA method is expressed as:

[0027]

[0028] in, The SVD decomposition results after retaining the topK singular values ​​and the corresponding singular vectors for the singular values ​​respectively;

[0029] In S22, the process of end-to-end training based on prompt optimization is as follows: the prompt encoder and the text of the large language model are aligned through adjustable parameters, and the parallel corpus of the general field is used to perform end-to-end training of the framework. After the large language model converges, the translation performance of the large language model is tested by the continuous prompts obtained by the prompt decoder training and the domain translation test set, so as to solve the translation tasks in different specific fields and obtain the trained large language model.

[0030] Furthermore, the step of constructing the optimized machine translation prompt comprises the following steps:

[0031] S31. Define the form of prompt instructions;

[0032] S32. Selection of limited samples;

[0033] S33 limits the coding range of the prompt encoder;

[0034] In said S31, the method adopted is to manually write the initialization prompt instruction, rely on the prompt encoder to convert the initialization text prompt into a continuous prompt, and dynamically iterate in the training process of each stage of the large language model;

[0035] In said S32, a method of enhanced retrieval generation is used to vectorize the samples in the sample library using a BGE model, and the top K results in the sample library are selected as prompt samples according to the text to be translated;

[0036] In S33, the effective information brought by the translation task by each component in the prompt is sorted in ascending order, namely: instructions, translation examples in the form of bilingual sentence pairs, and external knowledge introduced by the bilingual dictionary. Based on the above order, the component with the lowest information volume is compressed first, and the specific encoding range is instructions and translation examples.

[0037] The beneficial effects of the present invention are as follows: The present invention proposes a large language model machine translation enhancement method based on prompt optimization, which can automatically optimize prompts and shorten the length of input prompts of the large language model, thereby improving the translation performance of the large language model, and adopts a constructed prompt encoder to optimize and compress the input prompts of the large language model, and improves the efficient parameter fine-tuning method, thereby improving the translation performance of the large language model through end-to-end training; the present invention also proposes a retrieval enhancement generation method based on an external knowledge base to improve the translation performance of the large language model, which provides a good initialization for the input prompts of the large language model, thereby achieving better performance on the target translation task. BRIEF DESCRIPTION OF THE DRAWINGS

[0038] The drawings described herein are used to provide a further understanding of the present invention and constitute a part of the present invention. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the drawings:

[0039] Figure 1 A flowchart of a method for enhancing machine translation of large language models based on prompt optimization;

[0040] Figure 2 A flowchart of an embodiment of a method for enhancing machine translation of a large language model based on prompt optimization is provided;

[0041] Figure 3 Schematic diagram of the structure of a large language model based on a hint decoder. DETAILED DESCRIPTION

[0042] To make the technical solutions and advantages of the embodiments of the present invention more clearly understood, exemplary embodiments of the present invention are further described in detail below with reference to the accompanying drawings. It should be noted that the embodiments described are only a portion of the embodiments of the present invention, and are not an exhaustive list of all embodiments. It should be noted that the embodiments of the present invention and the features thereof may be combined with each other unless they conflict.

[0043] refer to Figure 1-Figure 3 This embodiment is described in detail. A method for enhancing machine translation of a large language model based on prompt optimization specifically includes the following steps:

[0044] S1. Pre-train and fine-tune the prompt decoder through the prompt decoder to obtain a pre-trained and fine-tuned prompt decoder, and construct a large language model based on the prompt decoder;

[0045] S2. Introduce the SVD-LoRA method to perform end-to-end training on the large language model based on the hint decoder to obtain the trained large language model;

[0046] S3. Based on the external knowledge base, construct optimized machine translation prompts, input the optimized machine translation prompts into the trained large language model, and obtain the target end sentence.

[0047] Furthermore, the step S1 specifically includes the following steps:

[0048] S11. Input the text into the prompt encoder of the constructed large language model, pre-train the prompt encoder with the help of the prompt decoder to obtain the hyperparameters of the prompt encoder, and compress the text length;

[0049] S12. Select input data based on the hyperparameters of the hint encoder and fine-tune the hint encoder;

[0050] In the S11, an unsupervised monolingual corpus is selected as text based on the main language of the large language model, and a prompt encoder is pre-trained. According to the text sequence of length M output by the prompt encoder, a text sequence of length N at the input end of the prompt encoder is restored by the prompt decoder. According to the effect of the prompt decoder restoring the text sequence during the pre-training process, the value of the hyperparameter M is determined so that the prompt encoder can compress the text sequence of length N to a text sequence of length M;

[0051] In S12, the hyperparameter M of the prompt encoder in the pre-training stage is initialized, and fine-tuning training is performed using the p-tuning method. During the fine-tuning process, a fine-tuning dataset of instructions for general fields and different tasks is input into the large language model, and the language is aligned with the language used in the pre-training stage of the prompt encoder. The instruction text of the data in the fine-tuning dataset is used as a continuous prompt. The input data and output data of the large language model are the source end sentences and the target end sentences of the parallel corpus, respectively. The parameters of the large language model are fixed, and the adjustable parameters are the parameters of the prompt encoder and the continuous prompt.

[0052] Specifically, refer to Figure 2 , Prompt Encoder is the prompt encoder, LLM is the large language model, Prompt Decoder is the prompt decoder, and soft prompt is the soft prompt. The main purpose of step S1 is to achieve prompt length compression and continuous tuning of prompts. These two goals are achieved in the pre-training and fine-tuning stages of the prompt encoder respectively;

[0053] In the pre-training stage, the large language model must be able to compress and represent the input prompts. Therefore, with the help of the prompt decoder structure, if the large language model can converge in the pre-training stage and the restoration effect of the prompt decoder is relatively impressive, it can be considered that the prompt encoder can compress the information of the text sequence of length N to the length sequence of length M, and the information loss in the compression process is acceptable. Since the goal of the pre-training stage is only to enable the prompt encoder to obtain the ability to compress text length, and the training method does not require supervised data, unsupervised monolingual corpus can be selected for training based on the main language of the large model. The role of the prompt decoder is only to assist the pre-training of the prompt encoder and will not participate in the subsequent large language model training process;

[0054] During the fine-tuning phase, in order to enable the prompt encoder to obtain the ability to continuously tune the input prompts, step S1 designs a targeted encoding module, namely the prompt encoder, for the input prompt part of the large language model, which effectively compresses and optimizes the input prompts of the large language model.

[0055] Furthermore, the step S2 specifically includes the following steps:

[0056] S21. Establish the SVD-LoRA method based on the LoRA method, and construct a large language model based on the prompt decoder combined with the SVD-LoRA method;

[0057] S22. Performing end-to-end training based on prompt optimization on the large language model based on the prompt decoder combined with the SVD-LoRA method to obtain a trained large language model;

[0058] In S21, the process of the LoRA method is expressed as follows:

[0059]

[0060] in, is the weight of the large language model before training, Additional weight for LoRA bypass, is a constant, based on With the current layer The scaling ratio of is approximately obtained, is the current layer;

[0061] exist 、 The process of the LoRA method at time 0 is expressed as:

[0062]

[0063] in, is the first low-rank matrix, is the second low-rank matrix;

[0064] The process of SVD-LoRA method is to use the current layer SVD decomposition results For the first low-rank matrix and the second low-rank matrix Initialize;

[0065] The process of the SVD-LoRA method is expressed as:

[0066]

[0067] in, The SVD decomposition result after retaining the topK singular values ​​and the corresponding singular vectors for the singular values ​​can be approximated as proportional reduction.

[0068] In S22, the process of end-to-end training based on prompt optimization is as follows: the prompt encoder and the text of the large language model are aligned through adjustable parameters, and the parallel corpus of the general field is used to perform end-to-end training of the framework. After the large language model converges, the translation performance of the large language model is tested by the continuous prompts obtained by the prompt decoder training and the domain translation test set, so as to solve the translation tasks in different specific fields and obtain the trained large language model.

[0069] Specifically, the LoRA method ensures that the initialization parameters of the large language model at the beginning of training are consistent with the parameters of the pre-trained model, that is, the prompt encoder. However, in the initial stage of training using the traditional LoRA method, the LoRA method cannot directly use the weight matrix As a result, the LoRA method does not fully utilize the information of the pre-trained model parameters;

[0070] The SVD-LoRA method overcomes the above problems. The K value required after SVD decomposition is equivalent to the rank in the LoRA method. The SVD-LoRA method does not affect the training process of large language models. Therefore, it can be considered that the computing power overhead of the SVD-LoRA method is equal to that of the LoRA method.

[0071] The present invention improves the prompt optimization method, referring to Figure 2 In the end-to-end training phase, i.e., step S22, the prompt encoder obtained in step S1 is used for initialization. The training process refers to the training method of the multimodal large model and is divided into three phases. The adjustable parameter of the first phase is the alignment layer between the prompt encoder and the large model, which is used to align the two text spaces. The second phase uses a common parallel corpus to perform end-to-end training of the framework to improve the translation capability of the model. The third phase performs fine-tuning for the specific field involved in the present invention to improve the final performance of the model.

[0072] Unlike the SVD-LoRA method which focuses on improving the overall translation ability of the model, the training at this stage focuses on solving translation tasks in different specific fields, using pre-designed prompts for initialization as Figure 2 The input of prompts in the program uses open-source parallel corpora in specific fields, which are Figure 1 The source sentence SourceSentence of the parallel corpus and the target sentence TargetSentence of the parallel corpus prompt the encoder to synchronously participate in the reasoning stage of the model. Since the translation tasks in different fields only differ in the parameters of the continuous prompt, the subsequent forward process of the large language model is the same. Therefore, a single model can be used to complete translation tasks in different fields in one batch, realizing the optimization of the model's reasoning efficiency. By optimizing the end-to-end training method of the large language model, the performance of the large language model on the target translation task is improved;

[0073] The main purpose of step S2 is to improve the efficient fine-tuning of parameters of large language models. In this regard, the existing technology has proposed a variety of different training methods. The main difference is that the trainable parameters are located in different positions of the model. The adjustable parameters of the LoRA method cover all steps of the forward process of the large language model, and have a stronger ability to represent the training data. However, in the prediction stage, it can only process one task in the same batch.

[0074] The adjustable parameters in a series of work based on prompt optimization cannot cover all the forward processes of the large language model. However, when predicting, the large language model has more common forward parts for different tasks, which can provide the possibility of processing multiple tasks in the same batch. The present invention adopts the above two training strategies at the same time, using the proposed SVD-LoRA method (combining singular value decomposition and low-rank adaptation methods) and parallel corpus in general fields to train the large language model, thereby improving the overall translation performance of the large model. For translation tasks in different sub-fields, the prompt optimization method is used for training, so that translation tasks in different fields can be grouped into a batch for inference, thereby improving the reasoning efficiency of the model.

[0075] Furthermore, the step of constructing the optimized machine translation prompt comprises the following steps:

[0076] S31. Define the form of prompt instructions;

[0077] S32. Selection of limited samples;

[0078] S33 limits the coding range of the prompt encoder;

[0079] In said S31, the method adopted is to manually write the initialization prompt instruction, rely on the prompt encoder to convert the initialization text prompt into a continuous prompt, and dynamically iterate in the training process of each stage of the large language model;

[0080] In said S32, a method similar to retrieval enhancement generation is used to vectorize the samples in the sample library using the BGE model, and the topK results in the sample library are selected as the prompt samples according to the text to be translated;

[0081] In S33, considering that the prompt text may lose information after being compressed by the prompt encoder, the prompt components are sorted in ascending order according to the effective information amount brought by the translation task, namely: instructions, translation examples in the form of bilingual sentence pairs, and external knowledge introduced by the bilingual dictionary. Based on the above order, the components with the lowest information amount are compressed first, and the specific encoding range is instructions and translation examples.

[0082] Specifically, the main purpose of step S3 is to design a good prompt initialization scheme for the continuous tuning training process, improve the information density of the large language model input prompts, compress the redundant parts of the prompts, and optimize the overall prompt part. The large language model input involved is divided into four parts: instructions, examples, external knowledge, and the text to be translated. Step S3 focuses on three sub-steps: the form of the prompt instruction, the selection of examples, and the encoding range of the prompt encoder;

[0083] In this embodiment, the prompt encoder is first pre-trained based on the process shown in step S1. Based on the pre-trained prompt encoder, the large language model is end-to-end trained according to the method of step S2. For translation tasks with supervised reference examples, the BGE model is used to build a sample library according to the method of step S3. Based on the sample library, the retrieved examples are spliced ​​in the prompt part to further improve the translation quality.

[0084] In English-Chinese translation tasks, if the large language model is trained according to the traditional training framework, for the source sentence to be translated, "Despite the complex geopolitical climate, international cooperation on climate change remains imperative for sustainable development.", the large language model will output "Despite the complex geopolitical climate, international cooperation on climate change remains imperative for sustainable development."; using the method proposed in the present invention for model training, the trained large language model will output "Despite the complex geopolitical environment, international cooperation on climate change remains vital for sustainable development.", presenting a more accurate translation effect for parts of the sentence such as "geopolitical environment."

[0085] Although the present invention has been described with respect to a limited number of embodiments, it will be apparent to those skilled in the art, having benefit of the foregoing description, that other embodiments are contemplated within the scope of the invention thus described. Furthermore, it should be noted that the language used in this specification has been selected primarily for readability and didactic purposes, rather than for the purpose of explaining or limiting the subject matter of the present invention. Consequently, many modifications and variations will be apparent to those skilled in the art without departing from the scope and spirit of the appended claims. The disclosure of the present invention is intended to be illustrative rather than restrictive of the scope of the invention, which is defined by the appended claims.

Claims

1. A large language model machine translation enhancement method based on prompt optimization, characterized in that: The following steps are involved: S1. Pre-train and fine-tune the prompt decoder through the prompt decoder to obtain a pre-trained and fine-tuned prompt decoder, and construct a large language model based on the prompt decoder; S2. Introduce the SVD-LoRA method to perform end-to-end training on the large language model based on the hint decoder to obtain the trained large language model; S3. Based on the external knowledge base, construct optimized machine translation prompts, input the optimized machine translation prompts into the trained large language model, and obtain the target end sentence; Said S1 specifically includes the following steps: S11. Input the text into the prompt encoder, pre-train the prompt encoder with the help of the prompt decoder to obtain the hyperparameters of the prompt encoder and the pre-trained prompt encoder; S12. Select input data based on the hyperparameters of the prompt encoder and fine-tune the pre-trained prompt encoder to obtain a fine-tuned prompt encoder; In the S11, an unsupervised monolingual corpus is selected as text based on the main language of the large language model, and a prompt encoder is pre-trained. According to the text sequence of length M output by the prompt encoder, a text sequence of length N at the input end of the prompt encoder is restored by the prompt decoder. According to the effect of the prompt decoder restoring the text sequence during the pre-training process, the value of the hyperparameter M is determined so that the prompt encoder compresses the text sequence of length N to a text sequence of length M; In S12, the hyperparameter M of the prompt encoder in the pre-training stage is initialized, and fine-tuning training is performed using the p-tuning method. During the fine-tuning process, a fine-tuning dataset of instructions for general fields and different tasks is input into the large language model, and the language is aligned with the language used in the pre-training stage of the prompt encoder. The instruction text of the data in the fine-tuning dataset is used as a continuous prompt. The input data and output data of the large language model are the source end sentences and the target end sentences of the parallel corpus, respectively. The parameters of the large language model are fixed, and the adjustable parameters are the parameters of the prompt encoder and the continuous prompt.

2. The method for enhancing large language model machine translation based on prompt optimization according to claim 1, characterized in that: Said S2 specifically includes the following steps: S21. Establish the SVD-LoRA method based on the LoRA method, and construct a large language model based on the prompt decoder combined with the SVD-LoRA method; S22. Performing end-to-end training based on prompt optimization on the large language model based on the prompt decoder combined with the SVD-LoRA method to obtain a trained large language model; In S21, the process of the LoRA method is expressed as follows: ; in, is the weight before the large language model starts training, Additional weight for LoRA bypass, is a constant, based on With the current layer The scaling ratio is obtained, is the current layer; exist 、 The process of the LoRA method at time 0 is expressed as: ; in, is the first low-rank matrix, is the second low-rank matrix; The process of SVD-LoRA method is to use the current layer SVD decomposition results For the first low-rank matrix and the second low-rank matrix Initialize; The process of the SVD-LoRA method is expressed as: ; in, The SVD decomposition results after retaining the topK singular values ​​and the corresponding singular vectors for the singular values ​​respectively; In S22, the process of end-to-end training based on prompt optimization is as follows: the prompt encoder and the text of the large language model are aligned through adjustable parameters, and the parallel corpus of the general field is used to perform end-to-end training of the framework. After the large language model converges, the translation performance of the large language model is tested by the continuous prompts obtained by the prompt decoder training and the domain translation test set, so as to solve the translation tasks in different specific fields and obtain the trained large language model.

3. The method for enhancing large language model machine translation based on prompt optimization according to claim 2, characterized in that: The step of constructing the optimized machine translation prompt comprises the following steps: S31. Define the form of prompt instructions; S32. Selection of limited samples; S33 limits the coding range of the prompt encoder; In said S31, the method adopted is to manually write the initialization prompt instruction, rely on the prompt encoder to convert the initialization text prompt into a continuous prompt, and dynamically iterate in the training process of each stage of the large language model; In said S32, a method of enhanced retrieval generation is used to vectorize the samples in the sample library using a BGE model, and the top K results in the sample library are selected as prompt samples according to the text to be translated; In S33, the effective information brought by the translation task by each component in the prompt is sorted in ascending order, and the component with the lowest information volume is compressed first based on the order of instructions, translation examples in the form of bilingual sentence pairs, and external knowledge introduced by the bilingual dictionary. The specific encoding range is instructions and translation examples.

Citation Information

Patent Citations

  • Fine tuning of diffusion-based generative neural networks for text-to-image generation using singular value decomposition

    CN119053994A

  • LLM-based network threat flow detection rule automatic generation method and system

    CN119299130A