Ensemble learning-oriented question and answer method and device under large model fine tuning

Through the reinforcement learning technology of integrated learning and human feedback, a robust reward model is constructed, which solves the problem of insufficient knowledge and generation inaccuracy of LLMs in specific fields, and improves the performance and adaptability of the model in multi-modal environments.

CN118761459AActive Publication Date: 2024-10-11BEIJING UNIV OF TECH

Patent Information

Application Number
CN202410740134.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-07
Publication Date
2024-10-11
Estimated Expiration
2044-06-07

AI Technical Summary

Technical Problem

LLMs face problems of insufficient knowledge coverage and inaccuracy of generated text in applications in specific fields, especially in multi-modal environments. Traditional fine-tuning methods rely on a large amount of annotated data and are difficult to obtain, and human preferences change rapidly, making it difficult to continuously adapt.

Method used

The integrated learning strategy is used to train the reward model. By pre-training the LLMs model and combining human feedback for reinforcement learning fine-tuning, a robust integrated reward model is constructed to optimize model behavior, reduce hallucinations, and improve sensitivity and accuracy to human feedback.

Benefits of technology

It achieves performance improvement of LLMs in specific fields, generates content that is more in line with human preferences, improves reliability and accuracy in multi-modal environments, is highly adaptable, and is suitable for diverse and changing user needs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118761459A_ABST
    Figure CN118761459A_ABST
Patent Text Reader

Abstract

The invention provides an ensemble learning-oriented question and answer method and device under large language model fine tuning. The method comprises the following steps: pre-training an LLMs model to obtain a reference LLMs model; training the reward model based on an integrated learning strategy to obtain an integrated reward model; performing fine adjustment on the reference LLMs model based on a reinforcement learning strategy according to a reward score output by the integrated reward model to obtain a target LLMs model; and inputting the question of the user into the target LLMs model to obtain an answer to the question. According to the method, the award model based on the ensemble learning strategy and the reinforcement learning technology based on human feedback are fused, so that accurate alignment of human preferences is realized, and the performance of LLMs in a specific field is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of artificial intelligence technology, and in particular to a question-answering method and device under large model fine-tuning for ensemble learning. Background Art

[0002] With the rapid development of artificial intelligence technology, LLMs (Large Language Models, LLMs) such as GPT-4 have made significant progress in the field of Natural Language Processing (NLP). These models can generate coherent and logical texts by learning from large amounts of text data, and show excellent performance in a variety of language tasks. However, despite the excellent general performance of LLMs, their application in specific fields still faces some challenges.

[0003] First, LLMs are usually trained on large-scale general datasets, which may lead to insufficient knowledge coverage of the model in specific fields. For example, in the industrial field, the model may need to understand specific industry terms, operating procedures, and safety specifications, which may not be common in general datasets. In addition, LLMs may experience the so-called "hallucination" phenomenon when generating text, that is, generating information that is inconsistent with reality or inaccurate, which is unacceptable in fields that require high accuracy.

[0004] In order to address these issues and improve the applicability and practicality of LLMs in specific domains, they need to be fine-tuned. The fine-tuning process aims to enable the model to generate text that meets the needs of a specific domain while reducing inaccurate or irrelevant outputs. However, traditional fine-tuning methods often rely on a large amount of labeled data, which may be difficult to obtain in some domains, especially in multimodal environments such as images and video content, where the annotation cost is higher.

[0005] In addition, human preferences and needs are diverse and change over time and with changing environments. Therefore, a method that can continuously adapt and accurately align human preferences is needed to improve the user experience and satisfaction of the model in practical applications. Summary of the invention

[0006] In view of the above problems existing in the prior art, the present invention provides a question answering method and device under fine-tuning of a large model for ensemble learning.

[0007] The present invention provides a question answering method under large model fine-tuning for ensemble learning, comprising:

[0008] Pre-train the LLMs model to obtain a benchmark LLMs model;

[0009] The reward model is trained based on the integrated learning strategy to obtain an integrated reward model;

[0010] Based on the reinforcement learning strategy, the benchmark LLMs model is fine-tuned according to the reward score output by the integrated reward model to obtain a target LLMs model;

[0011] Input the user's question into the target LLMs model to obtain the answer to the question.

[0012] According to a question-answering method for fine-tuning a large model for ensemble learning provided by the present invention, the reward model is trained based on the ensemble learning strategy to obtain an ensemble reward model, including:

[0013] Inputting the first data into the benchmark LLMs model multiple times to obtain answers to the first data output by the benchmark LLMs model, and generating a first question-answer pair according to the first data and the answers to the first data;

[0014] Obtaining manual revision results of each answer to the first data, and generating a second question-answer pair with the first data and the revision results of each answer;

[0015] sorting the first question-answer pair according to the quality of the first question-answer pair, sorting the second question-answer pair according to the quality of the second question-answer pair, wherein the sorting position of the second question-answer pair is before the sorting position of the first question-answer pair, and storing the first question-answer and the second question-answer in a feedback database according to the sorting results;

[0016] The reward model is trained using the feedback database based on an integrated learning strategy to obtain an integrated reward model.

[0017] According to a question-answering method for fine-tuning a large model for ensemble learning provided by the present invention, the reward model is trained using the feedback database based on the ensemble learning strategy to obtain an ensemble reward model, including:

[0018] Dividing the data in the feedback database into a training set and a validation set;

[0019] Training multiple reward models using different subsets of data and / or different hyperparameters in the training set;

[0020] Using the validation set to validate each trained reward model, and obtaining a performance indicator evaluation function value of each reward model on the validation set;

[0021] The multiple reward models are fused according to the performance indicator evaluation function values ​​of the respective reward models on the validation set to obtain an integrated reward model.

[0022] According to a question-answering method under large model fine-tuning for ensemble learning provided by the present invention, the weight of the ensemble reward model is obtained by the following formula:

[0023]

[0024] in, is the weight of the integrated reward model, is the i-th reward model RM i The weight of N is the number of reward models, P f (RM i ) is the performance index evaluation function value of the i-th reward model on the validation set, is the performance index evaluation function value of the i-th reward model on the first question-answer pair in the validation set, is the performance index evaluation function value of the i-th reward model on the second question-answer pair in the validation set, α is the preset adjustment coefficient, Greater than α is positive when , otherwise it is negative.

[0025] According to a question-answering method for fine-tuning a large model for ensemble learning provided by the present invention, the training of multiple reward models using different data subsets and / or different hyperparameters in the training set includes:

[0026] Inputting different data subsets and / or different hyperparameters in the training set into each reward model;

[0027] Determine the preference probability of each reward model according to whether the reward score of the training set output by each reward model is Markov;

[0028] Determining the loss function of each reward model according to the cross entropy loss between the preference probability of each reward model for the training set and the preset preference label;

[0029] The weights of the reward models are adjusted according to the loss functions of the reward models.

[0030] According to a question-answering method under large model fine-tuning for ensemble learning provided by the present invention, the reward model is a multilayer perceptron (MLP), a convolutional neural network (CNN) or a Transformer model.

[0031] According to a question-answering method for fine-tuning a large model for ensemble learning provided by the present invention, the reinforcement learning strategy is used to fine-tune the benchmark LLMs model according to the reward score output by the ensemble reward model to obtain a target LLMs model, including:

[0032] Inputting the second data into the benchmark LLMs model and the target LLMs model respectively, and obtaining answers to the second data output by the benchmark LLMs model and the target LLMs model;

[0033] Inputting the answers of the second data output by the benchmark LLMs model and the target LLMs model into the strategy model respectively to obtain a penalty term between the outputs of the strategy model;

[0034] Inputting the answer to the second data output by the target LLMs model into the integrated reward model to obtain a reward score output by the integrated reward model;

[0035] Determining a loss function of the target LLMs model according to the penalty term and the reward score;

[0036] The weight of the target LLMs model is adjusted according to the loss function of the target LLMs model.

[0037] According to a question answering method for fine-tuning a large model for ensemble learning provided by the present invention, after inputting the user's question into the target LLMs model and obtaining the answer to the question, the method further includes:

[0038] obtaining evaluation and modification of the user's answer to said question;

[0039] The evaluation and modification are used as new datasets to fine-tune the target LLMs model again.

[0040] The present invention also provides a question-answering device for fine-tuning a large model for ensemble learning, comprising:

[0041] A first pre-training module is used to pre-train the LLMs model to obtain a benchmark LLMs model;

[0042] A second pre-training module is used to train the reward model based on an integrated learning strategy to obtain an integrated reward model;

[0043] A fine-tuning module, used to fine-tune the benchmark LLMs model according to the reward score output by the integrated reward model based on a reinforcement learning strategy to obtain a target LLMs model;

[0044] The generation module is used to input the user's questions into the target LLMs model to obtain the answers to the questions.

[0045] The present invention also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the question-answering method under fine-tuning of a large model for ensemble learning as described above is implemented.

[0046] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the question-answering method under fine-tuning of a large model for ensemble learning as described in any of the above is implemented.

[0047] The present invention also provides a computer program product, including a computer program, which, when executed by a processor, implements the question-answering method under fine-tuning of a large model for ensemble learning as described in any of the above.

[0048] The question-answering method and device under large-model fine-tuning for ensemble learning provided by the present invention pre-train LLMs by using a large-scale data set to learn rich language and visual representations; fine-tune multiple reward models by applying the strategy of an ensemble learning reward model (Ensemble Learning Reward Model, ELRM) to build a robust ensemble reward model, which can effectively evaluate multimodal inputs; use reinforcement learning from human feedback (RLHF) technology to fine-tune the pre-trained LLMs to optimize their behavior and reduce hallucinations, while improving the model's sensitivity and accuracy to human feedback, and enhancing the performance and reliability of LLMs in multimodal environments; by fusing a reward model based on an ensemble learning strategy and a reinforcement learning technology based on human feedback, accurate alignment of human preferences can be achieved, thereby improving the performance of LLMs in specific fields. BRIEF DESCRIPTION OF THE DRAWINGS

[0049] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0050] Figure 1 This is one of the flow charts of the question-answering method under fine-tuning of a large model for ensemble learning provided by the present invention;

[0051] Figure 2 This is the second flow chart of the question-answering method under fine-tuning of a large model for ensemble learning provided by the present invention;

[0052] Figure 3 This is one of the flow diagrams of data collection and preprocessing in the question-answering method under fine-tuning of a large model for ensemble learning provided by the present invention;

[0053] Figure 4 This is the second flow chart of data collection and preprocessing in the question-answering method under fine-tuning of a large model for ensemble learning provided by the present invention;

[0054] Figure 5 It is a flow chart of reward model ensemble learning in the question-answering method under large model fine-tuning for ensemble learning provided by the present invention;

[0055] Figure 6 It is a flowchart of training a reward model in a question-answering method under fine-tuning of a large model for ensemble learning provided by the present invention;

[0056] Figure 7 It is a schematic diagram of the structure of the reward model in the question-answering method under fine-tuning of a large model for ensemble learning provided by the present invention;

[0057] Figure 8 It is a schematic diagram of the RLHF fine-tuning process in the question-answering method under large model fine-tuning for ensemble learning provided by the present invention;

[0058] Fig. 9 It is a flow chart of interactive feedback of terminals in the question-answering method under fine-tuning of a large model for ensemble learning provided by the present invention;

[0059] Fig.10 It is a structural schematic diagram of a question-answering device for fine-tuning a large model for ensemble learning provided by the present invention;

[0060] Fig.11 It is a structural schematic diagram of the electronic device provided by the present invention. DETAILED DESCRIPTION

[0061] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the drawings of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0062] Combine the following Figure 1 The present invention describes a question answering method for fine-tuning a large model for ensemble learning, comprising:

[0063] Step 101, pre-training the LLMs model to obtain a benchmark LLMs model;

[0064] LLMs models can be pre-trained on large-scale general datasets to learn rich language and visual representations.

[0065] The dataset can be multimodal data, including text, image, audio, video, etc. The dataset is preprocessed to meet the model input requirements.

[0066] The multimodal data is input into the LLMs model to perform the question-answer generation task. The parameters of the LLMs model are adjusted according to the error between the generated answer and the actual answer to obtain the benchmark LLMs model. The purpose is to enable the LLMs model to generate correct text output based on the given image and text prompts.

[0067] Step 102, training the reward model based on the integrated learning strategy to obtain an integrated reward model;

[0068] In the multimodal large model fine-tuning method, training the reward model is a key step, which involves the application of ensemble learning strategies and the construction of reward models. This step aims to enhance the performance of LLMs in multimodal tasks by integrating the predictions of multiple reward models.

[0069] The same reward model can be trained with different hyperparameters to obtain multiple reward models. The same reward model can also be trained with different data sets to obtain multiple reward models. The parameters of multiple reward models can be weighted and combined to form an integrated reward model.

[0070] Step 103, fine-tuning the benchmark LLMs model according to the reward score output by the integrated reward model based on a reinforcement learning strategy to obtain a target LLMs model;

[0071] The baseline LLMs model is fine-tuned using the reinforcement learning from human feedback (RLHF) technique and the reward score given by the integrated reward model to optimize its behavior and reduce hallucination phenomena, while improving the model's sensitivity and accuracy to human feedback.

[0072] Step 104, input the user's question into the target LLMs model to obtain the answer to the question.

[0073] The user's question can be multimodal data, including images, text prompts, and other possible modalities such as videos. The user's question is input into the target LLMs model as a prompt to obtain the answer generated by the target LLMs model.

[0074] Human preferences and needs are diverse and change over time and with changing environments. Therefore, a method that can continuously adapt and accurately align human preferences is needed to improve the user experience and satisfaction of the model in practical applications.

[0075] In practical applications, feedback can be collected through interaction with users to further fine-tune the target LLMs model to adapt to the changing user experience and preferences. The complete flowchart is as follows: Figure 2 shown.

[0076] This embodiment pre-trains LLMs using large-scale datasets to learn rich language and visual representations; fine-tunes multiple reward models by applying an integrated learning strategy to build a robust integrated reward model, which can effectively evaluate multimodal inputs; uses RLHF technology to fine-tune pre-trained LLMs to optimize their behavior and reduce hallucinations, while improving the model's sensitivity and accuracy to human feedback, thereby enhancing the performance and reliability of LLMs in multimodal environments; and integrates a reward model based on an integrated learning strategy and a reinforcement learning technology based on human feedback to achieve precise alignment of human preferences and improve the performance of LLMs in specific fields.

[0077] Based on the above embodiment, the reward model is trained based on the integrated learning strategy in this embodiment to obtain the integrated reward model, including:

[0078] Inputting the first data into the benchmark LLMs model multiple times to obtain answers to the first data output by the benchmark LLMs model, and generating a first question-answer pair according to the first data and the answers to the first data;

[0079] Obtaining manual revision results of each answer to the first data, and generating a second question-answer pair with the first data and the revision results of each answer;

[0080] sorting the first question-answer pair according to the quality of the first question-answer pair, sorting the second question-answer pair according to the quality of the second question-answer pair, wherein the sorting position of the second question-answer pair is before the sorting position of the first question-answer pair, and storing the first question-answer and the second question-answer in a feedback database according to the sorting results;

[0081] The reward model is trained using the feedback database based on an integrated learning strategy to obtain an integrated reward model.

[0082] The first data may be a general multimodal data resource, including images, text prompts, and other possible modalities such as videos.

[0083] like Figure 3As shown, in the multimodal large language model (MultiModel Large LanguageModels, MM-LLMs) fine-tuning method provided in this embodiment, data collection and preprocessing are the basis and key steps of the entire process, which directly affect the effect of subsequent model training and the performance of the final model. The specific steps include:

[0084] a. Multimodal input processing: It is necessary to collect and integrate multimodal data resources in order to stimulate the model's generation capabilities so that it can generate corresponding text output based on the input multimodal information. Specifically, it includes the following aspects:

[0085] Collect data: Collect image and text data from various sources, ensuring the diversity and coverage of the data to include different scenarios and topics.

[0086] Aggregate data: Pair the collected images with relevant textual prompts to form the input dataset. For example, a picture showing a spring field can be paired with a textual prompt describing the beauty of spring.

[0087] Generate question-answer pairs: Input the integrated data n times into MM-LLMs to perform the question-answer generation task. The model generates a series of question-answer pairs based on the input image and text prompts, labeled M1 to Mn, to form a generated dataset.

[0088] b. Manual quality control: The generated question-answer pairs may contain inaccurate or irrelevant information. Therefore, domain experts are required to conduct quality assessment and revision. Specifically, the following aspects are included:

[0089] Quality assessment: Invite domain experts to evaluate the generated question-answer pairs and screen them based on accuracy, relevance, fluency, and other criteria.

[0090] Revision and optimization: Revise the question and answer pairs that do not meet the standards, optimize the language expression, and ensure the accuracy and relevance of the information.

[0091] Forming an artificial dataset: The question-answer pairs that have been reviewed and revised by experts are re-labeled as H1 to Hn to form a high-quality artificial dataset.

[0092] c. Dataset sorting and optimization: In order to establish a dataset priority system with human evaluation as the core, the generated datasets and artificial datasets are prioritized. Specifically, the following aspects are included:

[0093] Sorting mechanism: The preliminary generated datasets and artificial datasets are prioritized according to human preferences, ensuring that the artificial datasets take precedence over the generated datasets in the sorting, that is, the sorting positions of H1 to Hn are better than M1 to Mn. This sorting strategy aims to establish a dataset priority based on human evaluation, but does not involve assigning specific scores to individual question-answer pairs, but only ensures that the overall order of the feedback database reflects human preferences and quality standards.

[0094] Optimize the dataset: Through sorting, the order of the overall dataset can reflect human preferences and quality standards, laying a solid data foundation for subsequent model training and fine-tuning.

[0095] from Figure 4 The entire process of data collection, integration, generation of question-answer pairs, manual quality control and data set sorting can be clearly seen in the figure. Each step has its own clear goals and operations to ensure the quality and applicability of the data set. The flowchart shows the various stages of data collection and preprocessing from left to right, and each stage has corresponding operations and outputs. The data starts with multimodal input processing on the left, goes through manual quality control in the middle, and finally reaches the data set sorting and optimization on the right.

[0096] In this embodiment, data collection and preprocessing play an important role in the MM-LLMs fine-tuning method, which not only improves the practicality and quality of the data set, but also provides important guarantees for the training efficiency of the model and the accuracy of the output, thereby ensuring the high performance of the model in practical applications.

[0097] On the basis of the above embodiment, the reward model is trained using the feedback database based on the integrated learning strategy in this embodiment to obtain an integrated reward model, including:

[0098] Dividing the data in the feedback database into a training set and a validation set;

[0099] Training multiple reward models using different subsets of data and / or different hyperparameters in the training set;

[0100] Using the validation set to validate each trained reward model, and obtaining a performance indicator evaluation function value of each reward model on the validation set;

[0101] The multiple reward models are fused according to the performance indicator evaluation function values ​​of the respective reward models on the validation set to obtain an integrated reward model.

[0102] The feedback database includes generated datasets and artificial datasets. The artificial dataset also includes training sets and validation sets. The validation set is used to evaluate the performance of multiple reward models.

[0103] The core idea of ​​ensemble learning of reward models is to leverage the diversity of multiple models to reduce reliance on a single model, thereby improving adaptability to distribution changes and robustness to label noise.

[0104] like Figure 5 As shown, we first pre-train multiple reward models (RMs) using the same reward model architecture by pre-training them on different data subsets of the same task, or using different hyperparameter settings such as learning rate, regularization strength, etc., to increase the diversity between models.

[0105] During the reward model fusion phase, each fine-tuned reward model independently provides reward predictions for the input sample, and the predicted rewards are weighted averaged to form the final reward score.

[0106] Train N RMs, denoted as {RM1, RM2, ..., RM N}. For a given input sample, each RM i A reward score will be output The weighted average reward is calculated as follows:

[0107]

[0108] in, is a given state-action pair (s t ,a t ), N is the number of reward models, P f (RM i ) is the performance index evaluation function value of the i-th reward model on the validation set.

[0109] The weights are allocated based on the performance of each reward model on the validation set and are calculated using the softmax function based on the performance metric to ensure that the model ensemble reflects the best performance.

[0110] This embodiment obtains an integrated reward model by effectively training and integrating the reward model, thereby improving its performance and robustness in multimodal tasks, which not only helps to improve the generation quality of LLMs, but also ensures that the generated content better meets human preferences and needs.

[0111] Based on the above embodiment, the weight of the integrated reward model in this embodiment is obtained by the following formula:

[0112]

[0113] in, is the weight of the integrated reward model, is the i-th reward model RM iThe weight of N is the number of reward models, P f (RM i ) is the performance index evaluation function value of the i-th reward model on the validation set, is the performance index evaluation function value of the i-th reward model on the first question-answer pair in the validation set, is the performance index evaluation function value of the i-th reward model on the second question-answer pair in the validation set, α is the preset adjustment coefficient, Greater than α is positive when , otherwise it is negative.

[0114] Based on the above embodiments, Figure 6 As shown, in this embodiment, using different data subsets and / or different hyperparameters in the training set to train multiple reward models includes:

[0115] Inputting different data subsets and / or different hyperparameters in the training set into each reward model;

[0116] Determine the preference probability of each reward model according to whether the reward score of the training set output by each reward model is Markov;

[0117] Determining the loss function of each reward model according to the cross entropy loss between the preference probability of each reward model for the training set and the preset preference label;

[0118] The weights of the reward models are adjusted according to the loss functions of the reward models.

[0119] The steps for training the reward model include the following:

[0120] Initialize the parameters and choose a reward model architecture, e.g. This is a parameterized function that is used to calculate the state-action pairs (s t ,a t ) prediction reward.

[0121] When calculating the preference probability of the reward model, the reward is divided according to whether it depends on the visited state, that is, whether it is Markov. The formula for calculating the preference probability based on Markov is as follows:

[0122]

[0123] Among them, P[σ1>σ0;ψ] represents the probability that trajectory σ1 is preferred over trajectory σ0 given the parameter ψ. is a parameterized reward function given in state s t and action a tThe expected reward under t is parameterized by ψ. t represents the time step. ψ is the parameter of the reward function, which is adjusted by the training data to maximize the prediction accuracy of human preferences.

[0124] For the preference probability in the non-Markov case, the following calculation formula is used:

[0125]

[0126] For non-Markov reward functions, in order to capture temporal dependencies, an importance weight w is introduced as a function of the entire trajectory segment, which enables the preference prediction model to assign importance within a trajectory segment.

[0127] The loss function of the reward model is:

[0128]

[0129] Among them, L CE (ψ) is the cross entropy loss function used to optimize the parameter ψ during training. D is a dataset containing multiple preference comparisons (σ0, σ1, y). y is a preference label indicating whether the human evaluator prefers trajectory σ1 over σ0 (y=1) or vice versa (y=0), or there is no difference between the two (y=0.5). Use gradient descent or other optimization algorithms to minimize the loss function L CE (ψ), thereby adjusting the parameter ψ of the reward model.

[0130] After training each reward model, multiple reward models trained with different parameters are integrated into one model to improve the generalization and robustness of the model.

[0131] Based on the above embodiments, the reward model in this embodiment is an MLP, CNN or Transformer model.

[0132] Select the corresponding reward model architecture according to the data type, including MLP, CNN and Transformer, etc. The specific structure is as follows Figure 7 As shown. The selected reward model is parameterized by the function Represents, used to calculate the state-action pair (s t ,a t ) prediction reward.

[0133] The MLP model uses a three-layer neural network structure, each layer contains N hidden units, and uses the ReLU activation function. N is an exponential power of 2. To ensure the stability of reward learning, an integration of K reward models is used, and the output is constrained within the range of [-1,1], and the tanh function is used for restriction. The minimum value of K is 3.

[0134] The CNN model improves on the MLP structure and adopts a three-layer CNN structure, with different kernel sizes and numbers of filters in each layer. Since the tanh activation function may cause the gradient to disappear in the visual environment, the output layer does not use an activation function.

[0135] The Transformer model uses the Preference Transformer, which includes the Causal Transformer and the Preference Attention Layer. Given a trajectory state-action segment, an embedding is first generated through a linear layer and then input into the Transformer network to generate an output embedding. The preference attention layer receives the output hidden embedding and generates a reward and importance weight.

[0136] Based on the above embodiments, Figure 8 As shown, in this embodiment, the benchmark LLMs model is fine-tuned according to the reward score output by the integrated reward model based on the reinforcement learning strategy to obtain the target LLMs model, including:

[0137] Inputting the second data into the benchmark LLMs model and the target LLMs model respectively, and obtaining answers to the second data output by the benchmark LLMs model and the target LLMs model;

[0138] Inputting the answers of the second data output by the benchmark LLMs model and the target LLMs model into the strategy model respectively to obtain a penalty term between the outputs of the strategy model;

[0139] Inputting the answer to the second data output by the target LLMs model into the integrated reward model to obtain a reward score output by the integrated reward model;

[0140] Determining a loss function of the target LLMs model according to the penalty term and the reward score;

[0141] The weight of the target LLMs model is adjusted according to the loss function of the target LLMs model.

[0142] The second data can be data from a specific field, such as data in an industrial production environment. Using the RLHF technique, the target LLMs are fine-tuned according to the reward score provided by the ELRM. The loss function includes a reward score and a KL divergence penalty term to ensure that the model does not deviate too far from the initial strategy while pursuing high rewards.

[0143] The loss function of the reinforcement learning fine-tuning objective LLMs is as follows:

[0144]

[0145] Among them, π INIT It is the initial strategy model with basic multimodal capabilities. The policy attempts to generate the most appropriate response for each user query. The model is optimized through reinforcement learning, and the symbol φ represents the model parameters. It is a dataset containing all collected images and user prompts, represented by (I, x), where I is the image, x is the prompt, and I and x together constitute the state parameter s t .s t It is a strategy model The generated output is usually a prediction or action given the input. In the case of vision-language models, a t This could be a description of an image, an answer to a question, or any form of textual output related to the visual content. The penalty term is the degree to which the policy model deviates from the initial policy model, preventing the model from over-optimizing the reward signal and ignoring other possible problems (such as generating unrealistic content). β is a hyperparameter that controls the importance of KL divergence.

[0146] On the basis of the above embodiments, after inputting the user's question into the target LLMs model and obtaining the answer to the question, the present embodiment further includes:

[0147] obtaining evaluation and modification of the user's answer to said question;

[0148] The evaluation and modification are used as new datasets to fine-tune the target LLMs model again.

[0149] Terminal interactive feedback is the key to improving the performance of LLMs after RLHF fine-tuning. Through real-time user interaction and feedback loops, the model is continuously optimized and adjusted. Fig. 9 As shown, the detailed optimization steps include the following:

[0150] Integration and configuration of interactive platform: Integrate the LLMs fine-tuned by RLHF with the interactive platform (such as Streamlit) to ensure that the system can process and display the input and output of image-prompt word pairs. Configure the user interface of the interactive platform to support real-time input submission and output display, and provide necessary user guidance and help documents.

[0151] Real-time display and user evaluation: Users submit N pairs of image-prompt word pairs through the interactive platform, and LLMs process them in real time and generate corresponding outputs. The generated results are displayed instantly on the interactive platform, and users can make preliminary evaluations of the results, such as satisfaction ratings, selective feedback, etc.

[0152] Human feedback: A dedicated feedback module is set up to allow users to conduct in-depth evaluation and modification of the model's output. Users can make specific suggestions for improving the generated content, such as correcting errors, enhancing the clarity or relevance of expression, etc.

[0153] Iterative dataset update: Integrate user evaluations and modifications into a new dataset that reflects users’ direct feedback and optimization suggestions on model output. Use the updated dataset to perform a new round of fine-tuning on LLMs in order to achieve better performance in future generation tasks.

[0154] Model performance monitoring and optimization: Continuously monitor the performance changes of LLMs and analyze the impact of user feedback on the quality of model output. Adjust fine-tuning strategies and model parameters based on performance monitoring results and user feedback to achieve continuous optimization of the model.

[0155] In the process of fine-tuning the LLMs model, the baseline LLMs play the role of the baseline model, and obtain the basic ability to handle industrial tasks through supervised fine-tuning (SFT). The performance level of the baseline LLM provides an important reference point for the continuous optimization of the target LLM. As the performance of the target LLMs gradually improves during the training process, the best performing model will be selected as the new baseline LLMs. This mechanism ensures that the performance benchmark always keeps pace with the current optimal effect, thereby maintaining its relevance and effectiveness in the evaluation process.

[0156] At the end of each training phase, the texts generated by the target LLMs will be submitted to industry experts for detailed evaluation. Experts will provide professional feedback based on the accuracy of the text content, its relevance to industrial practice, and its applicability in actual operations. The feedback information will be collated and incorporated into the feedback database, which is the core of the terminal interactive feedback.

[0157] The feedback database not only records the text samples generated by the model, but also contains detailed expert comments and suggestions for improvement. This data is used to make key updates to the reward model, ensuring that the reward model can more accurately map the preferences of human experts and fully consider the specific needs of the industrial field. In this way, each iteration of the model can be closer to the complexity and dynamics of the actual industrial environment, thereby providing users with more accurate, reliable and efficient artificial intelligence support.

[0158] The large model fine-tuning method provided in this embodiment involves an ELRM method, which can improve the performance and adaptability of LLMs in the industrial field by combining with the RLHF method. Figure 6 and Fig. 9 This method enhances the multimodal understanding and generation capabilities of LLMs by integrating the predictions of multiple reward models.

[0159] In the industrial field, accurate information understanding and efficient communication are crucial. In order to improve the performance of LLMs in processing industrial-related queries and tasks, this paper describes in detail how to apply the ELRM-based RLHF method to improve the reliability and generalization of LLMs in the industrial field, such as Figure 5 and Figure 8 This method enhances the multimodal understanding and generation capabilities of LLM by integrating the predictions of multiple reward models. The specific implementation steps are as follows:

[0160] Feedback database construction in industrial scenarios: In industrial application scenarios, it is crucial to build an accurate and practical feedback database to ensure that the output of LLM can meet the specific needs of the industrial field. Develop a feedback database specifically for the industrial field, which consists of two parts: generated datasets and artificial datasets.

[0161] The generated dataset comes from text samples such as maintenance guides, safety regulations, and equipment maintenance manuals that are automatically generated by LLMs based on industrial images and operation prompts. The artificial dataset contains samples such as case analysis, operation process descriptions, and troubleshooting guides that are carefully reviewed and annotated by experienced industrial engineers and technicians. These samples have undergone strict quality control to ensure the high accuracy and practicality of the data. In the artificial dataset, it is further subdivided into training sets and validation sets. The training set is used to train and adjust the reward model so that it can accurately evaluate the industrial-related texts generated by LLMs; the validation set is used to test and verify the evaluation ability of the reward model to ensure its effectiveness and reliability in actual industrial applications.

[0162] Build and train baseline LLM and target LLM: Use the feedback database in industrial scenarios to perform supervised fine-tuning (SFT) on LLM to further optimize the performance of LLM to learn rich language and visual representations to better adapt to the specific needs of the industrial field.

[0163] This embodiment uses the ELRM-RLHF method to significantly improve the application performance of LLMs in the industrial field. The model can generate more accurate, relevant, and easy-to-understand text outputs to better meet the needs of industrial experts and technicians. In addition, the adaptability and user-friendliness of the model are also enhanced, providing users with more satisfactory artificial intelligence services. Through continuous iterative optimization, the model can remain efficient and reliable in a constantly changing industrial environment.

[0164] The question-answering device under large model fine-tuning for ensemble learning provided by the present invention is described below. The question-answering device under large model fine-tuning for ensemble learning described below and the question-answering method under large model fine-tuning for ensemble learning described above can be referenced to each other.

[0165] like Fig.10 As shown, the device includes a first pre-training module 1001, a second pre-training module 1002, a fine-tuning module 1003 and a generating module 1004, wherein:

[0166] The first pre-training module 1001 is used to pre-train the LLMs model to obtain a benchmark LLMs model;

[0167] The second pre-training module 1002 is used to train the reward model based on the integrated learning strategy to obtain an integrated reward model;

[0168] The fine-tuning module 1003 is used to fine-tune the benchmark LLMs model according to the reward score output by the integrated reward model based on the reinforcement learning strategy to obtain a target LLMs model;

[0169] The generation module 1004 is used to input the user's question into the target LLMs model to obtain the answer to the question.

[0170] This embodiment pre-trains LLMs using large-scale datasets to learn rich language and visual representations; fine-tunes multiple reward models by applying the ELRM strategy to build a robust integrated reward model, which can effectively evaluate multimodal inputs; uses RLHF technology to fine-tune the pre-trained LLMs to optimize their behavior and reduce hallucinations, while improving the model's sensitivity and accuracy to human feedback, and enhancing the performance and reliability of LLMs in multimodal environments; integrates a reward model based on an integrated learning strategy and a reinforcement learning technology based on human feedback to achieve precise alignment of human preferences and improve the performance of LLMs in specific fields.

[0171] Fig.11 An example of a physical structure diagram of an electronic device is shown in FIG. Fig.11As shown, the electronic device may include: a processor 1110, a communication interface 1120, a memory 1130 and a communication bus 1140, wherein the processor 1110, the communication interface 1120 and the memory 1130 communicate with each other through the communication bus 1140. The processor 1110 may call the logic instructions in the memory 1130 to execute the question-answering method under the fine-tuning of the large model for ensemble learning, the method comprising: pre-training the LLMs model to obtain a benchmark LLMs model; training the reward model based on the ensemble learning strategy to obtain an ensemble reward model; fine-tuning the benchmark LLMs model according to the reward score output by the ensemble reward model based on the reinforcement learning strategy to obtain a target LLMs model; inputting the user's question into the target LLMs model to obtain the answer to the question.

[0172] In addition, the logic instructions in the above-mentioned memory 1130 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on such an understanding, the technical solution of the present invention can be essentially or partly embodied in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM), random access memory (RAM), disk or optical disk, etc., various media that can store program codes.

[0173] On the other hand, the present invention also provides a computer program product, which includes a computer program. The computer program can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can execute the question-answering method under large model fine-tuning for ensemble learning provided by the above methods. The method includes: pre-training the LLMs model to obtain a baseline LLMs model; training the reward model based on an ensemble learning strategy to obtain an ensemble reward model; fine-tuning the baseline LLMs model according to the reward score output by the ensemble reward model based on a reinforcement learning strategy to obtain a target LLMs model; inputting the user's question into the target LLMs model to obtain the answer to the question.

[0174] On the other hand, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, is implemented to execute the question-answering method under large model fine-tuning for ensemble learning provided by the above-mentioned methods, the method comprising: pre-training the LLMs model to obtain a baseline LLMs model; training the reward model based on an ensemble learning strategy to obtain an ensemble reward model; fine-tuning the baseline LLMs model according to the reward score output by the ensemble reward model based on a reinforcement learning strategy to obtain a target LLMs model; inputting the user's question into the target LLMs model to obtain the answer to the question.

[0175] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.

[0176] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.

[0177] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A question answering method for fine-tuning a large model for ensemble learning, characterized in that: include: Pre-train the LLMs model to obtain a benchmark LLMs model; The reward model is trained based on the integrated learning strategy to obtain an integrated reward model; Based on the reinforcement learning strategy, the benchmark LLMs model is fine-tuned according to the reward score output by the integrated reward model to obtain a target LLMs model; Input the user's question into the target LLMs model to obtain the answer to the question.

2. The question answering method under large model fine-tuning for ensemble learning according to claim 1, characterized in that: The reward model is trained based on the integrated learning strategy to obtain an integrated reward model, including: Inputting the first data into the benchmark LLMs model multiple times to obtain answers to the first data output by the benchmark LLMs model, and generating a first question-answer pair according to the first data and the answers to the first data; Obtaining manual revision results of each answer to the first data, and generating a second question-answer pair with the first data and the revision results of each answer; sorting the first question-answer pair according to the quality of the first question-answer pair, sorting the second question-answer pair according to the quality of the second question-answer pair, wherein the sorting position of the second question-answer pair is before the sorting position of the first question-answer pair, and storing the first question-answer and the second question-answer in a feedback database according to the sorting results; The reward model is trained using the feedback database based on an integrated learning strategy to obtain an integrated reward model.

3. The question answering method under large model fine-tuning for ensemble learning according to claim 2, characterized in that: The step of training the reward model using the feedback database based on the integrated learning strategy to obtain an integrated reward model includes: Dividing the data in the feedback database into a training set and a validation set; Training multiple reward models using different subsets of data and / or different hyperparameters in the training set; Using the validation set to validate each trained reward model, and obtaining a performance indicator evaluation function value of each reward model on the validation set; The multiple reward models are fused according to the performance indicator evaluation function values ​​of the respective reward models on the validation set to obtain an integrated reward model.

4. The question answering method under large model fine-tuning for ensemble learning according to claim 3, characterized in that: The weight of the integrated reward model is obtained by the following formula: in, is the weight of the integrated reward model, is the i-th reward model RM i The weight of N is the number of reward models, P f (RM i ) is the performance index evaluation function value of the i-th reward model on the validation set, is the performance index evaluation function value of the i-th reward model on the first question-answer pair in the validation set, is the performance index evaluation function value of the i-th reward model on the second question-answer pair in the validation set, α is the preset adjustment coefficient, Greater than α is positive when , otherwise it is negative.

5. The question answering method under large model fine-tuning for ensemble learning according to claim 3, characterized in that: The training of multiple reward models using different data subsets and / or different hyperparameters in the training set includes: Inputting different data subsets and / or different hyperparameters in the training set into each reward model; Determine the preference probability of each reward model according to whether the reward score of the training set output by each reward model is Markov; Determining the loss function of each reward model according to the cross entropy loss between the preference probability of each reward model for the training set and the preset preference label; The weights of the reward models are adjusted according to the loss functions of the reward models.

6. The question answering method under large model fine-tuning for ensemble learning according to any one of claims 1 to 5, characterized in that: The reward model is a multi-layer perceptron, a convolutional neural network or a Transformer model.

7. The question answering method under large model fine-tuning for ensemble learning according to any one of claims 1 to 5, characterized in that: The reinforcement learning strategy is used to fine-tune the benchmark LLMs model according to the reward score output by the integrated reward model to obtain a target LLMs model, including: Inputting the second data into the benchmark LLMs model and the target LLMs model respectively, and obtaining answers to the second data output by the benchmark LLMs model and the target LLMs model; Inputting the answers of the second data output by the benchmark LLMs model and the target LLMs model into the strategy model respectively to obtain a penalty term between the outputs of the strategy model; Inputting the answer to the second data output by the target LLMs model into the integrated reward model to obtain a reward score output by the integrated reward model; Determining a loss function of the target LLMs model according to the penalty term and the reward score; The weight of the target LLMs model is adjusted according to the loss function of the target LLMs model.

8. The question answering method under large model fine-tuning for ensemble learning according to any one of claims 1 to 5, characterized in that: After inputting the user's question into the target LLMs model and obtaining the answer to the question, the method further includes: obtaining evaluation and modification of the user's answer to said question; The evaluation and modification are used as new datasets to fine-tune the target LLMs model again.

9. A question-answering device for fine-tuning a large model for ensemble learning, characterized in that: include: A first pre-training module is used to pre-train the LLMs model to obtain a benchmark LLMs model; A second pre-training module is used to train the reward model based on an integrated learning strategy to obtain an integrated reward model; A fine-tuning module, used to fine-tune the benchmark LLMs model according to the reward score output by the integrated reward model based on a reinforcement learning strategy to obtain a target LLMs model; The generation module is used to input the user's questions into the target LLMs model to obtain the answers to the questions.

10. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the program, the question-answering method under large model fine-tuning for ensemble learning as described in any one of claims 1 to 8 is implemented.

Citation Information

Patent Citations

  • Question and answer reply method, system and equipment based on human feedback and reinforcement learning

    CN116955576A

  • Method and device for training generative large language model based on knowledge base feedback

    CN117009490A

  • Multi-modal knowledge generation method and device based on feedback enhancement

    CN117035074A

  • Data processing method and device, electronic equipment and storage medium

    CN117573838A

  • Industrial question and answer model training method based on reinforcement learning and knowledge base matching

    CN117763127A

Cited By

  • Preference alignment model training method based on limited preference identifier sorting

    CN119202915A

  • Large model adaptation method and device, equipment and storage medium

    CN119558377A

  • Task processing method, computing device and computer readable storage medium

    CN119806850A

  • RLHF-based large language model generation content privacy protection method

    CN119830350A

  • Safety guardrail enhancement method and device for text generation large model and computer equipment

    CN119903524A