Large model fine tuning method and system based on suffix prompt learning and ensemble learning

Through the suffix prompt learning and integrated learning methods, the problem of unreasonable parameter initialization and insufficient domain knowledge fusion in fine-tuning of large models is solved, and efficient fine-tuning of the model under low resource conditions is achieved, which improves the model's adaptability and reasoning performance, and is suitable for resource-constrained scenarios.

CN120450090APending Publication Date: 2025-08-08NANJING UNIV
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202510414626.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-04-03
Publication Date
2025-08-08

AI Technical Summary

Technical Problem

The existing large-scale model efficient fine-tuning technology lacks the exploration of parameter initialization methods, insufficient domain knowledge fusion, and low multi-module coordination efficiency, which affects the convergence speed and training stability of the model, and has high computing resource requirements.

Method used

The suffix prompt learning and ensemble learning method are adopted to construct sub-data sets through re-sampling, combined with the knowledge distillation of the teacher-student model and task vector learning, and the model parameters are optimized using KL divergence, mean square error and negative log likelihood loss function, and a small number of trainable parameters are introduced for fine-tuning. The reasoning stage is constrained to prompt attention through masking mechanism.

Benefits of technology

Maintain model performance in a low resource environment, improve model adaptability and inference performance, reduce computing resource requirements, and enhance the generalization ability of the model in cross-task transfer learning and the stability of the generated results.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120450090A_ABST
    Figure CN120450090A_ABST
Patent Text Reader

Abstract

The invention discloses a large model fine tuning method and system based on a suffix prompt learning method and ensemble learning, and the method comprises the steps: carrying out the preprocessing of an existing data set, obtaining K subsets through the replacement sampling, enabling each subset to account for a specified percentage of the total, and constructing an artificial prompt; according to the teacher model and the student model, a predicted target word classification score is obtained through suffix prompt learning, through probability normalization, teacher knowledge is distilled to the student model by using a KL divergence loss function, and a prompt vector is initialized; an input task vector is obtained through context learning, and knowledge of the input task vector is distilled to a student model prediction vector by using a mean square error loss function; constructing a mixed loss function, and optimizing knowledge distillation and task feature learning; performing end-to-end optimization on the initialized prompt vector by using suffix prompt in combination with a negative log-likelihood loss function; during reasoning, after the optimized prompt vectors are spliced to the input vectors, suffix prompts share the input vector key value cache to generate output. According to the method, the adaptability and reasoning performance of the model are remarkably improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer science, and in particular to a large model fine-tuning method and system based on suffix prompt learning and ensemble learning. Background Art

[0002] Large language models are currently receiving increasing attention, and efficient fine-tuning techniques for large models are gaining widespread application. Due to the large number of parameters in large models, fine-tuning and aligning them for downstream tasks requires significant resource overhead. Efficient fine-tuning techniques for large models reduce computational costs and resource requirements by optimizing a small number of parameters or introducing additional small modules, while maintaining model performance.

[0003] For example, if you need to fine-tune a general large model into a domain-specific large model, since the training data during pre-training is relatively mixed and there may be a lack of a large amount of domain data, you need to fine-tune the model on the corresponding domain data. However, the model has a large number of parameters, and it is difficult to fine-tune the entire model with limited resources. In this case, freezing the model parameters and introducing a small number of parameters at appropriate locations can also achieve good results. Figure 1 As shown in the figure, the domain big model can provide more efficient and accurate domain-specific services based on the general big model.

[0004] However, existing efficient fine-tuning techniques for large models still have some shortcomings. First, they lack the exploration of initialization methods for newly introduced parameters and the integration of downstream knowledge, which can affect the model's convergence speed and training stability. Second, how to effectively utilize large model fine-tuning modules, so that multiple fine-tuning modules can improve model accuracy without significantly affecting model inference speed, is also a question worth considering. Summary of the Invention

[0005] Purpose of the invention: The present invention provides a large model fine-tuning method and system based on suffix prompt learning and ensemble learning, aiming to solve the problems of unreasonable parameter initialization, insufficient domain knowledge fusion and low efficiency of multi-module collaboration in the efficient fine-tuning of large models.

[0006] Technical solution: In order to achieve the above purpose, the present invention adopts the following technical solution:

[0007] First, a large model fine-tuning method based on suffix hint learning and ensemble learning includes the following steps:

[0008] After preprocessing the existing dataset, K sub-datasets are obtained through replacement sampling, each of which accounts for a specified percentage of the overall dataset, and artificial prompts are constructed for each task;

[0009] A knowledge distillation model is established, comprising a teacher model and a student model. The teacher model learns to predict the classification score r of the target word through suffix prompts and obtains a probability distribution p through a probability normalization function. The student model learns to predict the classification score s of the target word through suffix prompts and obtains a probability distribution q through a probability normalization function. A first loss function based on KL divergence is established based on p and q to distill the knowledge of the teacher model combined with the manual prompts into the student model and its initialization prompt vector.

[0010] Establish a task vector learning model, which obtains a representation vector v of the input task through contextual learning, uses the student model to obtain a predicted task vector u, and constructs a second loss function based on mean square error to distill the knowledge of the task vector v into the predicted task vector u;

[0011] In the training phase, end-to-end training is performed on K sub-datasets. During the training, a hybrid loss function is constructed by combining the first loss function based on KL divergence and the second loss function based on mean squared error. The weights of the two losses are balanced using hyperparameters. The initialization hint vector is optimized by combining suffix hint learning with the third loss function based on negative log-likelihood loss.

[0012] In the inference stage, the K suffix prompts obtained through training are concatenated with the input text respectively, and the attention range of each suffix prompt is constrained through a mask mechanism. The classification scores calculated based on the K suffix prompts combined with the input text are used to obtain the final prediction result.

[0013] Furthermore, the first loss function based on KL divergence is expressed as follows:

[0014] L1=D KL (p∥q)=Σ i p i log(p i / q i )

[0015]

[0016] Where L1=D KL (·) represents the KL divergence loss function, p i ,q i Represents the i-th component of the two probability distributions p and q, r i ,s i denote the logits obtained by the teacher model and the student model respectively, and softmax(·) denotes the probability normalization function.

[0017] Furthermore, the second loss function based on mean square error is expressed as follows:

[0018]

[0019] Among them L MSE (·) represents the mean square error loss function, and u represent the mean representation vector of the input task and the predicted task vector obtained by context learning, respectively, and N represents the number of training samples.

[0020] Furthermore, the hybrid loss function is:

[0021] L=λ1L1+λ2L2

[0022] Among them, λ1 and λ2 are hyperparameters used to balance the influence weights of the two parts of the loss, L1 is the first loss function based on KL divergence, and L2 is the second loss function based on mean square error.

[0023] Furthermore, the third loss function based on negative log-likelihood loss is expressed as:

[0024]

[0025] Among them L NLL (·) represents the negative log-likelihood loss, f(·) represents the prediction output function of the model, X i ,y i Represent the i-th input and output respectively, P represents the suffix prompt vector, and N represents the number of training samples.

[0026] Furthermore, the representation vector of the input task is obtained through context learning, including:

[0027] The hidden layer state is extracted at the position where the model predicts the target word, and its mean is calculated through the average pooling operation to represent the task features as the task vector.

[0028] Furthermore, the teacher model adopts Llama2-13B and the student model adopts Llama2-7B.

[0029] The second aspect is a large model fine-tuning system based on suffix prompt learning and ensemble learning, including:

[0030] The data preparation module is used to preprocess the existing dataset and obtain K sub-datasets through replacement sampling, where each sub-dataset accounts for a specified percentage of the overall dataset, and to construct artificial prompts for each task;

[0031] A knowledge distillation model construction module is used to establish a knowledge distillation model including a teacher model and a student model. The teacher model obtains a classification score r of the predicted target word through suffix prompt learning and obtains a probability distribution p through a probability normalization function; the student model obtains a classification score s of the predicted target word through suffix prompt learning and obtains a probability distribution q through a probability normalization function; a first loss function based on KL divergence is established based on p and q, and the knowledge of the teacher model combined with the manual prompt is distilled into the student model and its initialization prompt vector;

[0032] A task vector learning model construction module is used to establish a task vector learning model. The task vector learning model obtains the representation vector v of the input task through context learning, uses the student model to obtain the predicted task vector u, and constructs a second loss function based on mean square error to distill the knowledge of the task vector v into the predicted task vector u;

[0033] The training module is used to perform end-to-end training on K sub-datasets during the training phase. During the training, a hybrid loss function is constructed by combining a first loss function based on KL divergence and a second loss function based on mean squared error, and the weights of the two losses are balanced using hyperparameters. The module also optimizes the initialized hint vector using suffix hint learning combined with a third loss function based on negative log-likelihood loss.

[0034] The inference module is used to concatenate the K suffix hints obtained through training with the input text during the inference phase, constrain the attention range of each suffix hint through a masking mechanism, and obtain the final prediction result based on the classification scores calculated based on the K suffix hints combined with the input text.

[0035] In a third aspect, a computer device comprises: one or more processors; a memory; and one or more programs, wherein the one or more programs are stored in the memory and are configured to be executed by the one or more processors, and when the programs are executed by the processors, the steps of the large model fine-tuning method based on suffix prompt learning and ensemble learning as described in the first aspect of the present invention are implemented.

[0036] In a fourth aspect, a computer-readable storage medium stores a computer program thereon, which, when executed by a processor, implements the steps of the large model fine-tuning method based on suffix prompt learning and ensemble learning as described in the first aspect of the present invention.

[0037] Beneficial effects: (1) The present invention combines prompt learning and knowledge distillation, so that the model can still maintain good performance in a small sample environment, and is suitable for applications with low-resource languages and scarce data sets. Only a small number of trainable parameters need to be introduced to achieve the same accuracy of reasoning performance, avoiding the need for full fine-tuning of the entire model, greatly reducing the demand for computing resources, and making it suitable for resource-constrained scenarios such as mobile applications and edge computing. (2) During the knowledge distillation process, the present invention uses KL divergence loss to optimize the knowledge transfer between the teacher and student models, and combines MSE loss to optimize the task vector, so that the student model can better capture and retain key information. Through task vector distillation, the student model can efficiently learn the features of different tasks, thereby improving generalization ability, especially in cross-task transfer learning. (3) While maintaining a low computational overhead, the present invention significantly improves the adaptability and reasoning performance of the model. In addition, compared with a single prompt learning method, the present invention introduces an integrated learning strategy to enable multiple prompt modules to share the same key-value cache, thereby improving the reasoning correctness of the model while keeping the reasoning speed almost unchanged, and ensuring the stability and reliability of the generated results. BRIEF DESCRIPTION OF THE DRAWINGS

[0038] Figure 1 This is a schematic diagram of a usage scenario of the present invention;

[0039] Figure 2 It is a schematic diagram of the overall process of the present invention;

[0040] Figure 3 Initialize the model architecture for the knowledge distillation of the present invention;

[0041] Figure 4 The task vector distillation model architecture of the present invention;

[0042] Figure 5 This is a schematic diagram of the model inference of the present invention. DETAILED DESCRIPTION

[0043] The technical solution of the present invention is further described below with reference to the accompanying drawings.

[0044] Reference Figure 2 The present invention provides a large model fine-tuning method based on post-prompt tuning and ensemble learning, comprising the following steps:

[0045] S1. First, select a dataset suitable for a specific task, such as sentiment analysis, text classification, named entity recognition, etc., and clean the data to remove noisy data and improve data quality. At the same time, adopt data enhancement strategies such as synonym replacement and random masking to improve the robustness and generalization ability of the model. In order to help the teacher model better learn task information, carefully designed artificial prompts (Prompt) are spliced before the input text to guide the model to focus on task-related features. For example, in a sentiment analysis task, the prompt can be "The sentiment of this sentence is:". The design of the prompt can guide the model to generate task-related output.

[0046] The dataset was then divided into training, validation, and test sets, with the training set accounting for 80% of the total, and the validation and test sets each accounting for 10%. During the training phase, bootstrap sampling was used to randomly extract a sub-dataset of 60% of the total training set from the training set to construct training samples suitable for ensemble learning, improving the stability and generalization ability of the model.

[0047] S2, such as Figure 3 As shown, first select the training set data as the input text. In the artificial prompt distillation model, the artificial prompt is first spliced to the input text and input into the teacher model (Llama2-13B) with frozen parameters. The suffix prompt learning described in the present invention refers to splicing the artificial prompt to the input text as its suffix and inputting the model together for learning. The teacher model extracts the model prediction results (i.e., the predicted target word), generates corresponding logits and records them as r, and obtains the probability distribution p of the model output (i.e., the predicted target word) in the vocabulary by softmax normalization. At the same time, the prompt vector initialized based on the vocabulary vector is spliced to the word embedding vector of the input text and input into the student model (Llama2-7B) with frozen parameters. The student model extracts the model prediction results, generates logits and records them as s, and also obtains the probability distribution q by softmax normalization. In order to make the output probability distribution of the student model as close as possible to the output probability distribution of the teacher model, KL divergence is used as the loss function to optimize the prompt vector of the student model, thereby realizing knowledge distillation, so that the student model can effectively inherit the task knowledge of the teacher model.

[0048] The loss function based on KL divergence is expressed as follows:

[0049] L1=D KL (p∥q)=Σ i p i log(p i / qi)

[0050]

[0051] Where L1=D KL (·) represents the KL divergence loss function, p i ,q i Represents the i-th component of the two probability distributions p and q, r i ,s i denote the logits obtained by the teacher model and the student model respectively, and softmax(·) denotes the probability normalization function.

[0052] S3, such as Figure 4 As shown, the training set data is also selected as the input text and a certain number of samples are extracted from it. The in-context learning (ICL) method is used to extract task-related information from the hidden state of the model to optimize the model's adaptability to different tasks. For each sample in the input model, the hidden state of the model is extracted at the position of the model prediction result, and the task vector is constructed using the context information and task features encoded therein. Specifically, the model input is a context learning input example combined with the extracted samples. The hidden state at the position corresponding to the model prediction result is extracted from the middle layer of the model, and the hidden state vector is defined as the task vector v. That is, v is the task vector obtained by context learning. In order to enhance the stability of the task representation, the mean of the task vectors of all samples is calculated to obtain the global task vector At the same time, using the same method, the training phase combines the training samples to extract the hidden state of the training samples at the corresponding position of the model prediction result from the middle layer of the model, which is defined as the hidden state vector u. That is, u is the hidden state obtained during the model training process, also known as the prediction task vector. The present invention realizes task feature learning by distilling the information of v to u. In order to ensure that the hidden state of the model can effectively encode the task information, the mean square error (MSE) loss function is used to calculate the global task vector The deviation between the hidden state vector u and the model's hidden layer state vector u is used as the optimization target, thereby guiding the model's hidden layer representation to be as close to the task information as possible. Optimizing the task vector not only enhances the model's adaptability to different tasks but also allows the model to more accurately align with task requirements during inference, improving overall controllability and generalization performance.

[0053] The loss function based on mean square error is expressed as follows:

[0054]

[0055] Among them L MSE (·) represents the mean square error loss function, N represents the number of training samples, u and v represent the predicted task vector and the input task vector respectively. In practical applications, the input task vector uses the mean of the task representation vectors learned from the context, which is the global task vector Substitution.

[0056] During the training phase, a hybrid loss function is constructed by combining the knowledge distillation loss based on KL divergence and the mean square error loss based on the task vector. The weights of the two losses are balanced through hyperparameters to optimize the model's knowledge distillation and task feature learning. The hybrid loss function is:

[0057] L=λ1L1+λ2L2

[0058] Among them, λ1 and λ2 are hyperparameters used to balance the influence weights of the two parts of the loss.

[0059] S4. Post-prompt Tuning effectively guides the model to produce outputs that meet task requirements by concatenating a learnable prompt vector after the input text. Its core idea is to introduce a small number of trainable parameters (prompt vectors) to enable the model to quickly adapt to downstream tasks without significantly increasing model complexity. The prompt vectors are initialized using the knowledge distillation method and task feature learning method described earlier. During training, the prompt vectors are concatenated to the word embedding vectors of the input text to construct an enhanced input sequence. This allows the model to efficiently learn to align with downstream tasks without changing the original architecture, improving adaptability and generation quality. For example, if the input text is X and the prompt vector is P, the concatenated input is [X; P]. This concatenated input sequence is fed into a student model (such as Llama2-7B), and a loss function based on negative log-likelihood (NLL) loss is used to calculate the difference between the model's predictions and the true labels to optimize the model's parameters. Negative log-likelihood loss can effectively measure the deviation between the probability distribution generated by the model and the target distribution, thereby guiding the model to learn downstream task features more accurately and improve its performance in downstream tasks.

[0060] The loss function combined with the negative log-likelihood loss is expressed as:

[0061]

[0062] Among them L NLL (·) represents the negative log-likelihood loss, N represents the number of training samples, f(·) represents the prediction output function of the model, X i ,y i denote the i-th input and output respectively, and P denotes the suffix prompt vector.

[0063] S5, such as Figure 5As shown, during the inference phase, ensemble learning is first used to train K suffix hint vectors. These are then appended to the inference sample to enhance the model's adaptability to the task. To ensure information independence between the hint vectors and prevent mutual interference, a masking mechanism is introduced during inference to constrain the attention span of each suffix hint, ensuring that each hint focuses only on the input text and itself, without interfering with each other. This design allows each hint module to operate independently while still leveraging information from the input text, effectively guiding the model to produce high-quality output. The masking mechanism involves concatenating multiple suffix hints to form multiple hint modules after the input text during inference. However, the attention of subsequent hints to the preceding hint is set to zero, ensuring that each hint focuses solely on the input text. During inference, each suffix hint is combined with the input text to calculate the logits of the generated word. The final prediction result is the average of the K logits. Furthermore, to improve inference efficiency, all suffix hints share the same KV-cache; that is, when calculating attention, all hint modules share the same set of input text keys and values. This not only reduces repetitive computation but also ensures that the model effectively utilizes the combined information from multiple prompt modules without significantly increasing computational overhead, thereby improving model accuracy and stability. Compared to single-prompt reasoning, this method leverages the advantages of ensemble learning while maintaining nearly constant reasoning speed, enabling the model to demonstrate better generalization across diverse task scenarios.

[0064] The method of the present invention is suitable for natural language processing (NLP) tasks such as sentiment analysis and text classification, and is particularly suitable for low-resource and small-sample scenarios, and has broad application prospects.

[0065] Based on the same technical concept as the method embodiment, the present invention also provides a large model fine-tuning system based on suffix prompt learning and ensemble learning, including:

[0066] The data preparation module is used to preprocess the existing dataset and obtain K sub-datasets through replacement sampling, where each sub-dataset accounts for a specified percentage of the overall dataset, and to construct artificial prompts for each task;

[0067] A knowledge distillation model construction module is used to establish a knowledge distillation model including a teacher model and a student model. The teacher model obtains a classification score r of the predicted target word through suffix prompt learning and obtains a probability distribution p through a probability normalization function; the student model obtains a classification score s of the predicted target word through suffix prompt learning and obtains a probability distribution q through a probability normalization function; a first loss function based on KL divergence is established based on p and q, and the knowledge of the teacher model combined with the manual prompt is distilled into the student model and its initialization prompt vector;

[0068] A task vector learning model construction module is used to establish a task vector learning model. The task vector learning model obtains the representation vector v of the input task through context learning, uses the student model to obtain the predicted task vector u, and constructs a second loss function based on mean square error to distill the knowledge of the task vector v into the predicted task vector u;

[0069] The training module is used to perform end-to-end training on K sub-datasets during the training phase. During the training, a hybrid loss function is constructed by combining a first loss function based on KL divergence and a second loss function based on mean squared error, and the weights of the two losses are balanced using hyperparameters. The module also optimizes the initialized hint vector using suffix hint learning combined with a third loss function based on negative log-likelihood loss.

[0070] The inference module is used to concatenate the K suffix hints obtained through training with the input text during the inference phase, constrain the attention range of each suffix hint through a masking mechanism, and obtain the final prediction result based on the classification scores calculated based on the K suffix hints combined with the input text.

[0071] It should be understood that the large model fine-tuning system based on suffix prompt learning and integrated learning in the embodiment of the present invention can implement all the technical solutions in the above method embodiment, and the functions of its various functional modules can be specifically implemented according to the methods in the above method embodiments. The specific implementation process can refer to the relevant description in the above embodiment, which will not be repeated here.

[0072] The present invention also provides a computer device comprising: one or more processors; a memory; and one or more programs, wherein the one or more programs are stored in the memory and are configured to be executed by the one or more processors, and when the programs are executed by the processors, the steps of the large model fine-tuning method based on suffix prompt learning and ensemble learning as described above are implemented.

[0073] The present invention also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the large model fine-tuning method based on suffix prompt learning and ensemble learning as described above.

[0074] It will be understood by those skilled in the art that all or part of the steps to implement the above embodiments may be accomplished by hardware or by a program to instruct the relevant hardware to accomplish the steps, and the program may be stored in a computer-readable storage medium. In the context of the present invention, the computer-readable medium may be considered to be tangible and non-transitory. Non-limiting examples of non-transitory tangible computer-readable media include non-volatile memory circuits (e.g., flash memory circuits, erasable programmable read-only memory circuits, or mask read-only memory circuits), volatile memory circuits (e.g., static random access memory circuits or dynamic random access memory circuits), magnetic storage media (e.g., analog or digital tapes or hard disk drives), and optical storage media (e.g., CDs, DVDs, or Blu-ray discs), etc.

[0075] The program code for implementing the method of the present invention can be written in any combination of one or more programming languages. Such program code can be provided to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable data processing device so that when the program code is executed by the processor or controller, the functions / operations specified in the flow chart and / or block diagram are implemented. The program code can be executed entirely on the machine, partially on the machine, as a stand-alone software package, partially on the machine and partially on a remote machine, or entirely on a remote machine or server.

[0076] In addition, although adopting specific order to describe each operation, this should be understood as requiring such operation to be carried out in the specific order shown or in sequential order, or requiring all illustrated operations to be carried out to obtain desired result.Under certain environment, multitasking and parallel processing may be advantageous.Similarly, although comprising some specific implementation details in the above discussion, these should not be construed as limiting the scope of the present invention.Some features described in the context of independent embodiment can also be realized in single realization in combination.On the contrary, the various features described in the context of independent realization also can be realized in multiple realizations individually or in the mode of any suitable subcombination.

[0077] The preferred embodiments of the present invention are described in detail above. However, the present invention is not limited to the specific details in the above embodiments. Within the technical concept of the present invention, various equivalent transformations can be made to the technical solutions of the present invention, and these equivalent transformations all fall within the scope of protection of the present invention.

Claims

1. A large model fine-tuning method based on suffix hint learning and ensemble learning, comprising the following steps: After preprocessing the existing dataset, K sub-datasets are obtained through replacement sampling, each of which accounts for a specified percentage of the overall dataset, and artificial prompts are constructed for each task; A knowledge distillation model is established, comprising a teacher model and a student model. The teacher model learns to predict the classification score r of the target word through suffix prompts and obtains a probability distribution p through a probability normalization function. The student model learns to predict the classification score s of the target word through suffix prompts and obtains a probability distribution q through a probability normalization function. A first loss function based on KL divergence is established based on p and q to distill the knowledge of the teacher model combined with the manual prompts into the student model and its initialization prompt vector. Establish a task vector learning model, which obtains a representation vector v of the input task through contextual learning, uses the student model to obtain a predicted task vector u, and constructs a second loss function based on mean square error to distill the knowledge of the task vector v into the predicted task vector u; In the training phase, end-to-end training is performed on K sub-datasets. During the training, a hybrid loss function is constructed by combining the first loss function based on KL divergence and the second loss function based on mean squared error. The weights of the two losses are balanced using hyperparameters. The initialization hint vector is optimized by combining suffix hint learning with the third loss function based on negative log-likelihood loss. In the inference stage, the K suffix prompts obtained through training are concatenated with the input text respectively, and the attention range of each suffix prompt is constrained through a mask mechanism. The classification scores calculated based on the K suffix prompts combined with the input text are used to obtain the final prediction result.

2. The method according to claim 1, characterized in that The first loss function based on KL divergence is expressed as follows: L1=D KL (p∥q)=Σ i p i log(p i / q i ) Where L1=D KL (·) represents the KL divergence loss function, p i ,q i Represents the i-th component of the two probability distributions p and q, r i ,s i denote the logits obtained by the teacher model and the student model respectively, and softmax(·) denotes the probability normalization function.

3. The method according to claim 1, characterized in that The second loss function based on mean square error is expressed as follows: Among them L MSE (·) represents the mean square error loss function, and u represent the mean representation vector of the input task and the predicted task vector obtained by context learning, respectively, and N represents the number of training samples.

4. The method according to claim 1, wherein The hybrid loss function is: L=λ1L1+λ2L2 Among them, λ1 and λ2 are hyperparameters used to balance the influence weights of the two parts of the loss, L1 is the first loss function based on KL divergence, and L2 is the second loss function based on mean square error.

5. The method according to claim 1, wherein The third loss function based on negative log-likelihood loss is expressed as: Among them L NLL (·) represents the negative log-likelihood loss, f(·) represents the prediction output function of the model, X i ,y i Represent the i-th input and output respectively, P represents the suffix prompt vector, and N represents the number of training samples.

6. The method according to claim 1, characterized in that The representation vector of the input task is obtained through context learning, including: The hidden layer state is extracted at the position where the model predicts the target word, and its mean is calculated through the average pooling operation to represent the task features as the task vector.

7. The method according to claim 1, characterized in that The teacher model adopts Llama2-13B, and the student model adopts Llama2-7B.

8. A large model fine-tuning system based on suffix prompt learning and ensemble learning, characterized by: include: The data preparation module is used to preprocess the existing dataset and obtain K sub-datasets through replacement sampling, where each sub-dataset accounts for a specified percentage of the overall dataset, and to construct artificial prompts for each task; A knowledge distillation model construction module is used to establish a knowledge distillation model including a teacher model and a student model. The teacher model obtains a classification score r of the predicted target word through suffix prompt learning and obtains a probability distribution p through a probability normalization function; the student model obtains a classification score s of the predicted target word through suffix prompt learning and obtains a probability distribution q through a probability normalization function; a first loss function based on KL divergence is established based on p and q, and the knowledge of the teacher model combined with the manual prompt is distilled into the student model and its initialization prompt vector; A task vector learning model construction module is used to establish a task vector learning model. The task vector learning model obtains the representation vector v of the input task through context learning, uses the student model to obtain the predicted task vector u, and constructs a second loss function based on mean square error to distill the knowledge of the task vector v into the predicted task vector u; The training module is used to perform end-to-end training on K sub-datasets during the training phase. During the training, a hybrid loss function is constructed by combining a first loss function based on KL divergence and a second loss function based on mean squared error, and the weights of the two losses are balanced using hyperparameters. The module also optimizes the initialized hint vector using suffix hint learning combined with a third loss function based on negative log-likelihood loss. The inference module is used to concatenate the K suffix hints obtained through training with the input text during the inference phase, constrain the attention range of each suffix hint through a masking mechanism, and obtain the final prediction result based on the classification scores calculated based on the K suffix hints combined with the input text.

9. A computer device, characterized in that: include: one or more processors; Memory; And one or more programs, wherein the one or more programs are stored in the memory and are configured to be executed by the one or more processors, and when the programs are executed by the processors, the steps of the large model fine-tuning method based on suffix prompt learning and ensemble learning are implemented as described in any one of claims 1 to 7.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the large model fine-tuning method based on suffix prompt learning and ensemble learning are implemented as described in any one of claims 1 to 7.

Citation Information

Cited By

  • Plant variable splicing prediction method based on large model distillation and evidence constraint

    CN122337349A

  • Plant alternative splicing prediction method based on large model distillation and evidence constraint

    CN122337349B