WO2025253201A1 - 模型训练、数据处理的方法及设备 - Google Patents
模型训练、数据处理的方法及设备Info
- Publication number
- WO2025253201A1 WO2025253201A1 PCT/IB2025/054029 IB2025054029W WO2025253201A1 WO 2025253201 A1 WO2025253201 A1 WO 2025253201A1 IB 2025054029 W IB2025054029 W IB 2025054029W WO 2025253201 A1 WO2025253201 A1 WO 2025253201A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- instruction
- model
- instructions
- samples
- training set
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F18/00—Pattern recognition
- G06F18/20—Analysing
- G06F18/21—Design or setup of recognition systems or techniques; Extraction of features in feature space; Blind source separation
- G06F18/214—Generating training patterns; Bootstrap methods, e.g. bagging or boosting
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06N—COMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
- G06N3/00—Computing arrangements based on biological models
- G06N3/02—Neural networks
- G06N3/04—Architecture, e.g. interconnection topology
- G06N3/0495—Quantised networks; Sparse networks; Compressed networks
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06N—COMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
- G06N3/00—Computing arrangements based on biological models
- G06N3/02—Neural networks
- G06N3/08—Learning methods
- G06N3/09—Supervised learning
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06N—COMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
- G06N3/00—Computing arrangements based on biological models
- G06N3/02—Neural networks
- G06N3/08—Learning methods
- G06N3/096—Transfer learning
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06N—COMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
- G06N5/00—Computing arrangements using knowledge-based models
- G06N5/04—Inference or reasoning models
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/30—Information retrieval; Database structures therefor; File system structures therefor of unstructured textual data
- G06F16/33—Querying
- G06F16/3331—Query processing
Definitions
- instruction fine-tuning utilizes far less data than pre-training data to train the model's intrinsic capabilities and the extensive knowledge accumulated during the pre-training phase.
- knowledge distillation KD
- a language model with a larger number of parameters and higher capabilities can be used to fine-tune instructions for a language model with a smaller number of parameters (as a student model). This compresses the knowledge and capabilities of the teacher model into a smaller, more efficient student model, allowing the smaller model to maintain relatively high performance while reducing the demand for computing resources.
- this disclosure provides a model training method, comprising: using a reference model, selecting instructions from an existing instruction dataset whose model fitting difficulty meets preset conditions as seed instructions; expanding and generating multiple instruction samples based on the seed instructions, and constructing a training set containing the instruction samples and their reference responses; using the training set to train a deep learning model to obtain a trained target model.
- this disclosure provides a data processing method, comprising: receiving a call request from an end-side device for a target model, the call request including an input instruction; inputting the input instruction into the target model, generating a response result of the input instruction through the target model, wherein the target model is trained by: selecting seed instructions from an existing instruction dataset with model fitting difficulty meeting preset conditions using a reference model, generating multiple instruction samples based on the seed instructions, constructing a training set including the instruction samples and reference responses of the instruction samples, training a deep learning model using the training set, and obtaining a trained target model; and returning the response result of the input instruction to the end-side device.
- this disclosure provides a server, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, the instructions being executed by the at least one processor to cause the server to perform the method provided in any of the preceding aspects.
- this disclosure provides a computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, implement the method provided in any of the preceding aspects.
- this disclosure provides a computer program product, including a computer program that, when executed by a processor, implements the methods provided in any of the foregoing aspects.
- challenging instructions with high model fitting difficulty can be selected from the instruction dataset as seed instructions. Multiple similar instruction samples are generated based on the seed instructions, thus obtaining more challenging instruction samples. A training set containing instruction samples and their reference responses is constructed. Knowledge extraction based on the existing instruction dataset can be achieved using the reference model, resulting in a higher-quality training set of challenging instruction data. Furthermore, using this training set to train a deep learning model can improve the deep learning model's ability to handle more complex and challenging tasks, thereby improving the performance of the target model after training.
- the accompanying drawings which are incorporated in and constitute a part of this disclosure, illustrate embodiments consistent with this disclosure and, together with the description, serve to explain the principles of this disclosure.
- Figure 1 is a schematic diagram of an example system architecture to which this disclosure applies;
- Figure 2 is a flowchart of a neural network model training method provided by an exemplary embodiment of this disclosure;
- Figure 3 is a flowchart of a seed instruction selection process provided by an exemplary embodiment of this disclosure;
- Figure 4 is a flowchart of a training set construction based on seed instructions provided by an exemplary embodiment of this disclosure;
- Figure 5 is a schematic diagram of the proportion of each task type in an existing instruction dataset provided by an exemplary embodiment of this disclosure;
- Figure 6 is a schematic diagram of the preset task proportion of each task type provided by an exemplary embodiment of this disclosure;
- Figure 7 is a flowchart of a model training method provided by another exemplary embodiment of this disclosure;
- Figure 8 is a framework diagram of model training provided by an exemplary embodiment of this disclosure;
- Figure 9 is a flowchart of a data processing method provided by an exemplary embodiment of this disclosure;
- Figure 10 is a schematic diagram of the structure of a server
- the user information including but not limited to user device information, user attribute information, etc.
- data including but not limited to data used for analysis, stored data, displayed data, etc.
- the collection, use, and processing of related data must comply with relevant laws, regulations, and standards, and corresponding operation entry points are provided for users to choose to authorize or refuse.
- Instruction fine-tuning Also known as instruction optimization, it uses user instruction data and reference responses to fine-tune the large language model, enabling the large language model to generate responses that better match user preferences.
- the Alpaca dataset is an open-source instruction fine-tuning dataset based on handwritten seed data and model expansion, covering multiple tasks and domains including grammar, fashion, mathematics, and food.
- Visual question answering task Determine the answer to a question from the visual information of the input image, given the input image and the question.
- Image description task Generate descriptive text for the input image.
- Visual entailment task Predicting the semantic relevance between an input image and text, i.e., entailment, neutrality, or contradiction. Meaning expression and understanding task: Locating the image region in an input image that corresponds to the input text.
- Image generation task Generating an image based on the input descriptive text.
- Text-based sentiment classification task Predicting the sentiment classification information of the input text.
- Text summarization task Generating a summary of the input text.
- Multimodal task Downstream tasks involving multiple modalities of data, such as images and text, including visual question answering, image description, visual entailment, meaning expression and understanding, and image generation.
- Multimodal pre-trained model A pre-trained model involving multiple modalities of data, such as images and text, which, after fine-tuning, can be applied to multimodal task processing.
- Pre-trained language model A pre-trained model obtained by pre-training a Large Language Model (LLM). Large models refer to deep learning models with a massive number of parameters, typically containing hundreds of millions, tens of billions, or even trillions of parameters. Large models are also known as foundation models (FM).
- LLM Large Language Model
- These challenging instructions which have a high model fitting difficulty, are selected as seed instructions. Multiple similar instruction samples are then generated based on these seed instructions to obtain more challenging instruction samples. A training set containing these instruction samples and their reference responses is constructed. This allows for knowledge extraction based on the existing instruction dataset using the reference model, resulting in a training set of challenging instruction data. Furthermore, using this training set to train a deep learning model improves its ability to handle more complex and challenging tasks, thereby enhancing the performance of the target model after training.
- the model fitting difficulty of an instruction refers to the ease with which the model learns (or fits) the ability to process that instruction during training.
- FIG 1 is a schematic diagram of an example system architecture to which this disclosure applies.
- the system architecture includes a server and edge devices.
- the server and edge devices have a communication link, enabling communication between them.
- the server is a computing device deployed in the cloud or locally, such as a cloud cluster.
- the server is responsible for acquiring and storing the deep learning model to be trained, as well as existing instruction datasets. Based on the existing instruction dataset, the server can use a reference model to select instructions from the existing instruction dataset whose model fitting difficulty meets preset conditions as seed instructions.
- the deep learning model can be a natural language processing model based on at least one modality of information, such as images, speech, or text. Examples include various human-computer interaction models, models for text-to-text generation tasks (such as text summarization, translation, and question answering), speech-to-text models (such as speech recognition models), image-to-text models (such as OCR models and image summarization), and natural language understanding (NLU) models such as sentiment analysis, etc.
- text-to-text generation tasks such as text summarization, translation, and question answering
- speech-to-text models such as speech recognition models
- image-to-text models such as OCR models and image summarization
- NLU natural language understanding
- the deep learning model can be a lightweight model, a pre-trained model, or a large language model with relatively few parameters, or a multimodal language model, etc.
- This embodiment does not specifically limit the deep learning model.
- the reference model refers to a powerful pre-trained model. Compared to the deep learning model, the reference model has a larger number of parameters and stronger reasoning capabilities.
- a powerful pre-trained model applicable to the same scenario as the target model can be selected as the reference model, such as a large-scale or ultra-large-scale language model.
- the reference model can run on another cloud server (not shown in Figure 1).
- the server used to train the deep learning model in Figure 1 can call the reference model through its Application Programming Interface (API) and use its inference capabilities.
- API Application Programming Interface
- the reference model can also run on the server used to train the deep learning model in Figure 1; this is not specifically limited here.
- the edge device can be an electronic device running downstream applications, specifically a hardware device with network communication, computing, and information display capabilities, including but not limited to smartphones, tablets, desktop computers, local servers, and cloud servers.
- the edge device needs to use the target model's inference capabilities when running downstream applications.
- Downstream applications running on the edge device can perform natural language processing tasks such as text summarization, translation, and question answering; or speech-to-text tasks; or image-to-text tasks; or natural language understanding (NLU) tasks such as sentiment analysis.
- NLU natural language understanding
- the target model's inference capabilities are required.
- the target model infers based on the given input information to generate response results.
- the edge device implements subsequent processing logic for downstream applications based on the response results of the input information.
- the edge device sends user input information to the server.
- the server receives the input information, inputs it into the target model, generates a response result using the target model, and returns the response result to the edge device.
- the edge device receives the response result returned by the server and continues to execute subsequent processing logic based on it.
- the server can provide the API of the trained target model to the edge device.
- the edge device can send a call request for the target model to the server based on the API of the target model, and this call request contains the user's input information.
- the server receives the call request for the target model sent by the edge device, extracts the user's input information from the call request, generates a response result of the output information using the target model, and returns the response result to the edge device.
- the server can provide the trained target model (or the parameters of the trained target model) to the edge device.
- the edge device can use the trained target model locally and implement specific downstream application tasks based on the reasoning ability of the target model, such as natural language processing tasks like text summarization, translation, and question answering, or speech-to-text tasks, or image-to-text tasks, or natural language understanding (NLU) tasks like sentiment analysis.
- the trained target model can also be applied to other tasks in the field of artificial intelligence, which are not specifically limited here.
- Figure 2 is a flowchart of a neural network model training method provided by an exemplary embodiment of this disclosure.
- the execution subject of this embodiment is the server in the aforementioned system architecture.
- the method of this embodiment uses a reference model to perform knowledge extraction on the existing instruction dataset to construct a training set with a high model fitting difficulty for the instruction data.
- the instruction data included in this training set is challenging due to the high model fitting difficulty.
- Step S201 Using a reference model, select instructions from the existing instruction dataset that meet the preset conditions for model fitting difficulty as seed instructions.
- the existing instruction dataset can be from publicly available datasets, such as the Alpaca dataset, Guanaco dataset, or any existing dataset used for fine-tuning instructions in large language models. It can also be from private datasets provided by the user via an edge device, or instruction data automatically constructed using a large model; this embodiment does not impose specific limitations.
- the instruction dataset typically includes instruction-response pairs, which include both the instruction and its response.
- the reference model used for knowledge extraction can be configured and specified by relevant technical personnel according to user needs, or it can be specified by the user via an edge device.
- the reference model refers to a powerful pre-trained model. Compared to deep learning models, reference models have a larger number of parameters and stronger inference capabilities. Specifically, a powerful pre-trained model applicable to the same scenario as the target model can be selected as the reference model, such as a large-scale or ultra-large-scale language model.
- the deep learning model to be trained can be specified by the user via the edge device, or configured and specified by relevant technical personnel according to user needs.
- the deep learning model can be a natural language processing model based on at least one modality of information from images, speech, and text. Examples include various human-computer interaction models, models for text-to-text generation tasks (such as text summarization, translation, and question answering), speech-to-text models (such as speech recognition models), image-to-text models (such as OCR models and image summarization), natural language understanding (NLU) models such as sentiment analysis, and so on.
- the deep learning model can be a lightweight model, a pre-trained model, a large model with relatively few parameters, or a multimodal language model. This embodiment does not specifically limit the deep learning model.
- the server when the user needs to fine-tune the deep learning model, they send a model training request to the server via the edge device.
- This model training request contains information about the deep learning model to be trained and a reference model.
- the server based on information about the deep learning model to be trained and the reference model, can determine the reference model and the deep learning model to be trained specified by the edge device.
- the deep learning model has fewer parameters than the reference model.
- the server needs to use a lightweight deep learning model instead of a large model to provide services to the edge device.
- the server can use the large model as a reference model, perform knowledge extraction using the reference model, and train the lightweight deep learning model.
- the server uses the trained target model to provide services to the edge device.
- the model fitting difficulty of the instructions in the instruction dataset is evaluated using the reference model, and instructions whose model fitting difficulty meets preset conditions are selected from the existing instruction dataset.
- These challenging instructions are then used as seed instructions for constructing a challenging training set.
- the preset conditions can be that the model fitting difficulty is greater than or equal to a difficulty threshold, and based on these conditions, challenging instructions with higher model fitting difficulty can be selected.
- the difficulty threshold 6 can be configured and adjusted based on the range of the instruction response quality evaluation value and the actual application scenario.
- the range of the instruction response quality evaluation value can be [1, 10], and the difficulty threshold 6 can be 2 or 3, etc., without specific limitations.
- the preset condition can be that the task type of the instruction belongs to a predefined task type set.
- This task type set includes various task types with high model fitting difficulty and specific challenges, including but not limited to: mathematical, logical reasoning, and programming-related tasks.
- the server uses the reference model to determine the task type of the instructions in the existing instruction dataset, and selects instructions whose task type belongs to the predefined task type set from the instruction dataset as instructions whose model fitting difficulty meets the preset condition, thus obtaining challenging instructions as seed instructions for constructing a challenging training set.
- Step S202 Generate multiple instruction samples based on the seed instructions, and construct a training set containing instruction samples and reference responses of the instruction samples.
- the server uses the reference model to generate multiple similar instructions based on the seed instructions as instruction samples for constructing the training set. Further, the server generates reference responses for instruction samples using a reference model, obtaining instruction sample-reference response pairs consisting of instruction samples and their reference responses, and constructs a training set containing instruction samples and their reference responses (i.e., instruction sample-reference response pairs).
- This training set can be used for instruction fine-tuning and contains instruction data with specific challenges.
- the reference response of an instruction sample is a high-quality response to the instruction sample, which can be understood as the correct response or labeled response of the instruction sample.
- Step S203 Train a deep learning model using the training set to obtain a trained target model. After obtaining a challenging training set, use this training set to fine-tune the deep learning model to obtain a trained target model.
- the server inputs instruction samples from the training set into the deep learning model for response prediction, determining the probability that the deep learning model predicts the reference response of the output instruction sample.
- a first loss is calculated based on the resampling weights of the instruction samples and the probability that the deep learning model predicts the reference response of the output instruction sample; the parameters of the deep learning model are adjusted based on the first loss to obtain the trained target model.
- the resampling weights of instruction samples correspond to the task type of the instruction samples, with instruction samples of the same task type having the same resampling weights.
- Different task types may have different resampling weights. For more complex and challenging task types, such as mathematical, logical reasoning, and programming-related tasks, larger resampling weights can be configured, while simpler task types are configured with smaller resampling weights.
- This implementation based on the autoregressive causal language modeling loss used in existing instruction fine-tuning, increases the resampling weights for instruction samples with similar characteristics across different tasks, and weights the losses of different instruction samples. This gives the model task-awareness during instruction fine-tuning, allowing it to focus more on more complex and challenging tasks, thereby improving the model's ability to handle more complex and challenging tasks.
- ⁇ represents the training set constructed based on the seed instruction. ( ⁇ , ⁇ ) represents any instruction sample-reference response pair in the training set ⁇ , ⁇ represents the instruction sample, and ⁇ represents the reference response of the instruction sample ⁇ .
- T( ⁇ , ⁇ ) represents Pr[T(x £ , y £ )] represents the resampling weight corresponding to task type T(%i, yi).
- Pr[yJ%i, 1] represents the probability that the deep learning model predicts the reference response based on the instruction sample, that is, the probability that the deep learning model predicts the correct prediction result.
- the server inputs the instruction samples in the training set into the deep learning model for response prediction, determines the probability that the deep learning model predicts the reference response of the output instruction sample; calculates the second loss based on the probability that the deep learning model predicts the reference response of the output instruction sample; adjusts the parameters of the deep learning model based on the second loss, and obtains the target model after training.
- the server directly uses the autoregressive causal language modeling loss as the second loss to train the deep learning model.
- the following formula (2) can be used to calculate the second loss based on the probability that the deep learning model predicts the reference response of the output instruction sample: logPr[y £
- the training strategy used to train the deep learning model using the training set including but not limited to the selected optimization algorithm, learning rate, etc., can be configured and adjusted according to the actual application scenario, and no specific limitation is made here.
- the server can provide the target model to the edge device.
- the server can provide an interface for calling the target model to the edge device.
- the edge device can send a request to the server to call the target model based on the interface, and this request includes user input information.
- the server receives the request from the edge device, extracts the user input information from the request, generates a response result with output information from the target model, and returns the response result to the edge device.
- the server can send the parameters of the target model to the edge device.
- the edge device initializes the parameters of the locally stored deep learning model according to the parameters of the target model to obtain the trained target model.
- the server can also send download information for the target model to the edge device.
- the edge device downloads the pre-trained target model to its local machine according to the received download information.
- the server provides the target model obtained through knowledge vaporization to the edge device, allowing the edge device to store the target model locally and use its inference capabilities locally.
- the server uses a reference model to select instructions from the existing instruction dataset whose model fitting difficulty meets preset conditions. Specifically, it selects challenging instructions with high model fitting difficulty as seed instructions. Based on these seed instructions, multiple similar instruction samples are generated, resulting in more challenging instruction samples. A training set containing instruction samples and their reference responses is then constructed. By using the reference model to perform knowledge vaporization on the existing instruction dataset, a training set of challenging instruction data is obtained.
- instructions whose fitting difficulty meets preset conditions are selected from the existing instruction dataset using a reference model as seed instructions.
- the deep learning model is fine-tuned using the instruction dataset to obtain a fine-tuned model; the predicted response of the instructions in the instruction dataset is generated using the fine-tuned model, and a reference response of the instructions is generated using the reference model; based on the quality difference between the predicted response and the reference response, the model fitting difficulty (MFD) of the instructions is determined, and instructions whose model fitting difficulty meets preset conditions are selected as seed instructions.
- MFD model fitting difficulty
- the preset conditions can be that the model fitting difficulty is greater than or equal to a difficulty threshold.
- the difficulty threshold can be configured and adjusted according to the range of the instruction response quality evaluation value and the actual application scenario.
- the range of the instruction response quality evaluation value can be [1, 10]
- the difficulty threshold can be 2 or 3, etc., without specific limitations.
- Figure 3 is a flowchart of the seed instruction selection process provided in this embodiment. As shown in Figure 3, the specific process of selecting seed instructions that meet the preset conditions for fitting difficulty from the existing instruction dataset with the help of a reference model is as follows: Step S300: Obtain the existing instruction dataset.
- the existing instruction dataset can come from publicly available instruction datasets, such as open-source datasets like the Alpaca dataset and Guanaco dataset, or any existing dataset used for fine-tuning instructions in large language models.
- the existing instruction dataset can also come from private datasets provided by users through end-side devices, or instruction data automatically constructed using large models. This embodiment does not make specific limitations here.
- the instruction dataset usually includes instruction-response pairs, which include instructions and their responses.
- Step S301 Fine-tune the deep learning model using the instruction dataset to obtain a fine-tuned model.
- the deep learning model (denoted by S) is fine-tuned using the existing instruction dataset to obtain a fine-tuned model (denoted by So).
- Step S302 Generate the predicted responses of the instructions in the instruction dataset through the fine-tuned model.
- the fine-tuned model So after fine-tuning the instructions in the instruction dataset, generates the response to the instructions in the instruction dataset, called the predicted response.
- This step aims to evaluate the deep learning model's ability to generate responses from a large number of instructions without complex training. Based on the basic capabilities of centralized learning.
- Step S303 Generate reference responses for instructions in the instruction dataset using a reference model. In this step, the responses for instructions in the instruction dataset generated using a reference model are called reference responses.
- Step S304 Evaluate the quality of the predicted responses and reference responses of the instructions using a referee model to obtain the quality evaluation values of the predicted responses and reference responses.
- the referee model is used to evaluate the response quality of the predicted responses generated by the fine-tuning model S30 and the reference responses generated by the reference model, obtaining the quality evaluation values of the predicted responses and reference responses.
- the referee model can be implemented using any existing algorithm/model for evaluating the response quality of instructions; for example, the referee model can be implemented using a large language model (LLM). For example, pre-configured quality evaluation prompts are obtained, and the instructions, their predicted responses, and reference responses are filled into the quality evaluation prompts and then input into the referee model.
- LLM large language model
- quality assessment prompts can define other rules or requirements for conducting quality assessments, such as output format, providing evaluation basis/reasons, etc., which are not specifically limited here.
- quality assessment prompts can define other rules or requirements for conducting quality assessments, such as output format, providing evaluation basis/reasons, etc., which are not specifically limited here.
- the output format is as follows: Evaluation Basis: ⁇ Your evaluation description here> Score of Smart Assistant 1: VScore1 > Score of Smart Assistant 2: VScore2>".
- ⁇ Instruction ⁇ represents the instruction to be filled
- ⁇ answer_1 ⁇ and ⁇ answer_2 ⁇ represent the predicted response and reference response to be filled.
- ⁇ Your evaluation description here> represents the evaluation basis (reason) output by the judging model
- VScore1 > represents the quality evaluation value of ⁇ answer” ⁇ output by the judging model
- VScore2 > represents the quality evaluation value of ⁇ answer_2 ⁇ output by the judging model.
- the quality evaluation value of each response is constrained to take values in the interval [1, 10].
- the judging model can obtain the quality evaluation values of the two responses (including the predicted response and the reference response) of the instruction in one inference, and the quality evaluation values of the predicted response and the reference response are more comparable.
- a referee model can be used to evaluate the predicted response of the instruction based on the instruction and the predicted response of the instruction, obtaining a quality evaluation value for the predicted response of the instruction; the referee model can also evaluate the reference response of the instruction based on the instruction and the reference response of the instruction, obtaining a quality evaluation value for the reference response of the instruction.
- Step S305 Determine the model fitting difficulty of the instruction based on the difference between the quality evaluation value of the reference response and the quality evaluation value of the predicted response. After obtaining the quality evaluation values of the reference response and the predicted response of the instruction, the reference response of the instruction is used as a benchmark, and the difference between the quality evaluation value of the reference response and the quality evaluation value of the predicted response is calculated. The larger the difference, the worse the quality of the predicted response generated by the deep learning model compared to the reference response generated by the reference model.
- the difference between the quality evaluation value of the reference response and the quality evaluation value of the predicted response is used as the model fitting difficulty (MFD) of the instruction.
- the difference between the quality evaluation value of the reference response and the quality evaluation value of the predicted response can also be multiplied by a scaling factor and used as the model fitting difficulty (MFD) of the instruction.
- the scaling factor can be configured according to actual application needs and empirical values, and is not specifically limited here.
- the model fitting difficulty (MFD) evaluation index is introduced to measure the model fitting difficulty of the instruction, that is, the difficulty of the model learning to obtain the correct response to the instruction.
- the model fitting difficulty of the instruction is determined according to the quality difference between the predicted response and the reference response of the instruction.
- challenging seed instructions can be selectively screened from the existing instruction dataset.
- Step S306 Select instructions from the instruction dataset whose model fitting difficulty meets the preset conditions as seed instructions.
- a preset condition is configured as the filtering condition to select challenging instructions.
- this step filters out instructions from the instruction dataset whose MFD meets the preset condition as seed instructions.
- the preset condition can be that the MFD is greater than or equal to a difficulty threshold, and based on this preset condition, challenging instructions with a high MFD can be selected.
- the difficulty threshold 6 can be configured and adjusted according to the range of the instruction response quality assessment value and the actual application scenario.
- the range of the instruction response quality assessment value can be [1, 10]
- the difficulty threshold 6 can be 2 or 3, etc., without specific limitations here.
- the preset condition can be that the task type of the instruction belongs to a predefined task type set.
- This task type set includes various task types with high MFD and specific challenges, including but not limited to: mathematical, logical reasoning, and programming-related tasks.
- the server uses a reference model to determine the task type of the instructions in the existing instruction dataset, and filters out instructions whose task type belongs to a predefined set of task types. These instructions are then selected as those whose model fitting difficulty meets preset conditions, thus obtaining challenging instructions that serve as seed instructions for constructing a challenging training set.
- the method in this embodiment generates predicted responses for the instructions in the instruction dataset by fine-tuning the deep learning model using the existing instruction dataset, and generates reference responses for the instructions in the instruction dataset using the reference model. The reference responses and predicted instruction evaluation values are obtained through a judge model evaluation.
- FIG. 4 is a flowchart of constructing a training set based on seed instructions provided in an exemplary embodiment of this disclosure.
- Step S202 Using a reference model, based on the seed instructions and the task type of the seed instructions, similar instructions and responses of the same task type are generated as instruction samples and reference responses of instruction samples. In this embodiment, the reference model is used to generate similar instructions based on the seed instructions.
- the similar instructions have the same task type as the seed instructions, and are also comparable to the seed instructions in terms of instruction length and difficulty.
- pre-configured instruction generation prompt information is obtained, and the seed instructions and the task type of the seed instructions are filled into the instruction generation prompt information and then input into the reference model. Based on the reference model, prompts are generated to produce new instructions similar to the seed instruction.
- the similar instructions must be of the same task type as the seed instruction, and...
- the instruction length and difficulty are comparable to the seed instruction.
- the instruction generation prompts can define constraints on the length, difficulty, and content of the instruction sample to be generated; these are not specifically limited here. For example, below is an example of an instruction generation prompt:
- a reference response to the instruction sample is generated using the reference model. For example, a pre-configured response generation prompt is obtained, the instruction sample is filled into the response generation prompt, and then input into the reference model.
- the reference model generates prompts based on the response, and a reference response for the instruction sample is generated.
- the prompts generated in the response can use prompts from any existing question-answering model; no specific limitations are imposed here.
- an example of the prompts generated in the response is as follows:
- ⁇ Instruction ⁇ represents the instruction sample to be filled
- ⁇ answer> represents the reference response generated by the reference model.
- the task ratio of the instruction samples generated by the reference model is required to meet a balanced quota, that is, the proportion of instruction samples of each task type in the generated instruction samples is required to match the preset task ratio.
- the task ratio of each task type is configured, with an increased proportion in key task types such as mathematics, logical reasoning, and programming.
- Figure 5 provides a schematic diagram of the proportion of instruction data of each task type in the existing instruction dataset
- Figure 6 provides a schematic diagram of the configured task ratio of each task type.
- the horizontal axis represents the quantity of instruction data
- the vertical axis represents the different task types of the instruction data.
- a large proportion of the instruction data belongs to simple tasks such as Common-Sense, Technology, Grammar, Literature, and Others, while instruction data for challenging task types such as Math, Reasoning, and Code (including Code Generation and Code Debugging) is relatively scarce.
- the instruction data primarily consists of challenging task types such as Math, Reasoning, and coding (including Code Generation and Code Debugging), increasing the proportion of key task types like Math, Reasoning, and Programming, while other simpler task types have a smaller proportion of instruction data.
- the task proportions for each task type can be configured as follows: Math, Reasoning, Code Generation, and Code Debugging are configured at 0.167:0.167:0.083:0.083, with these four task types accounting for 50% in total, and the remaining tasks evenly distributing the remaining 50%.
- the task types and their proportions can be configured according to the needs of the actual application scenario; no specific limitations are imposed here.
- Figures 5 and 6 also include Writing, Computer Science, Law, and Medicine.
- the task data includes various task types such as Medicine, Art, and Music.
- Other task types in Figures 5 and 6 may not be entirely consistent.
- the inclusion of other task types can be configured according to actual needs and will not affect the technical effectiveness of this solution.
- Figures 5 and 6 emphasize the proportion of instruction data for challenging task types such as Math, Reasoning, and Code (including Code Generation and Code Debugging).
- the server can configure resampling weights for each task type according to a preset task ratio. Based on these resampling weights, the server samples seed instructions for each task type from the seed instructions and generates similar instructions of the same task type as instruction samples based on the sampled seed instructions. The number of similar instructions generated at one time based on any seed instruction is the same. For task types with larger resampling weights, the seed instructions of the corresponding task type are sampled more times, resulting in a larger number of instruction samples of the corresponding task type. This allows control over the proportion of instruction data for each task type in the constructed training set.
- the server can randomly sample seed instructions for each task type to generate instruction samples for the corresponding task type; and construct a training set containing all generated instruction samples. Then, based on a preset task ratio, some instruction samples in the training set are deleted, so that the proportion of instruction data for each task type in the adjusted training set matches the preset task ratio.
- the server when generating a reference response for an instruction sample using a reference model, the server obtains the corresponding prompt information for the task type based on the task type of the instruction sample.
- the prompt information for different task types can be different.
- the prompt information for any task type contains detailed requirements for responding to the instructions of that task type, used to prompt the reference model to generate better reference responses for that task type.
- the prompt information for any complex task type can also include a Chain of Thought (CoT).
- the Chain of Thought breaks down the reasoning process of the instructions for the corresponding task type into multiple steps, prompting the reference model to reason step by step to generate reference responses for the instruction samples, which can improve the quality of the generated reference responses.
- the reference model generates reference responses for instruction samples based on the prompt information for the corresponding task type.
- prompt information for code generation is as follows:
- Task Instruction ⁇ Instruction ⁇ Your Response: ⁇ answer>
- ⁇ Instruction ⁇ represents the instruction sample to be filled in
- ⁇ answer> represents the reference response generated by the reference model.
- the prompt "Please provide a code snippet with annotations and then explain it” is a specific requirement for code generation tasks, requiring the generated code snippet to include annotations and explanations.
- a simple example of a prompt containing a thought chain is as follows:
- Task Instruction: ⁇ Instruction ⁇ Your Response: ⁇ answer> represents the instruction sample to be filled in
- ⁇ answer> represents the reference response generated by the reference model.
- the prompt "Please think and answer in detail following these steps: Step 1...; Step 2" outlines the reasoning steps defined by the thought chain, requiring the reference model to think and answer in detail based on these steps, i.e., to provide a reference response by reasoning step by step. This is merely an example, and the specific details of each step are omitted. The specific steps can be configured according to the actual tasks of the application.
- a reference model can be used to classify the instructions. For example, after filling the task classification prompt information with the instruction, it is input into the reference model. The reference model then determines the task type of the instruction based on the prompt information. The task classification prompt information is used to prompt the reference model to classify the given instruction.
- the specific content of the task classification prompt information can be reconfigured according to the needs of the actual application scenario; no specific limitations are made here. For example, based on the task types shown in Figure 6, an example of task classification prompt information is as follows:
- Task types or domains are listed below: ['Math', 'Code Generation 5 ', 'Writing', 'Computer']"
- Step S2022 Construct a training set containing instruction samples and their reference responses. After obtaining instruction samples and their reference responses that match the preset task ratio, construct a training set containing these instruction samples and their reference responses. The method in this embodiment, through a reference model, generates similar instructions and responses of the same task type based on seed instructions and their task types, serving as instruction samples and reference responses.
- FIG. 7 is a flowchart of a model training method provided in another exemplary embodiment of this disclosure.
- the first round of iterative training based on the fine-tuned model obtained by fine-tuning the deep learning model using an existing instruction dataset, seed instructions whose model fitting difficulty meets preset conditions are selected from the instruction dataset using a reference model, and these are used as the seed instructions for the first round.
- a training set for the first round is constructed based on the seed instructions for the first round, and the initial deep learning model is trained using the training set for the first round.
- instruction samples whose model fitting difficulty meets preset conditions are selected from the training set for the previous round using a reference model, and these are used as the seed instructions for the current round.
- Step S700 Obtain the existing instruction dataset.
- the existing instruction dataset can be derived from publicly available instruction datasets, such as the Alpaca dataset, the Guanaco dataset, or any existing dataset used for fine-tuning instructions in large language models.
- Existing instruction datasets can also originate from private datasets provided by users via edge devices, or instruction data automatically constructed using large models; this embodiment does not impose specific limitations.
- the instruction dataset typically includes instruction-response pairs, which include both the instruction and its response.
- seed instructions whose model fitting difficulty meets preset conditions are selected from the instruction dataset using a reference model. These seed instructions are used as the first round's seed instructions.
- the first round's training set is constructed based on these seed instructions, and the initial deep learning model is trained using the first round's training set. See steps S701-S703 for details. Step S701: Using a reference model, select instructions from the existing instruction dataset whose model fitting difficulty meets preset conditions as the first round's seed instructions.
- Step S702 Based on the first-round seed instructions, multiple instruction samples are generated and the first-round training set is constructed. The principle of this step is consistent with the principle of step S202 above. For details, please refer to the relevant content of the aforementioned embodiments, which will not be repeated here.
- Step S703 The initial deep learning model is trained using the first-round training set.
- the deep learning model is fine-tuned using the first-round training set to obtain the deep learning model obtained from the first round of iterative training.
- resampling weights are added to instruction samples with similar characteristics across different tasks. The losses for different instruction samples are then weighted, enabling the model to acquire task-aware capabilities during instruction fine-tuning. This allows the model to focus more on more complex and challenging tasks, thereby improving its ability to handle more complex and challenging tasks.
- the server inputs instruction samples from the first round of training into the deep learning model for response prediction, determining the probability that the deep learning model predicts the reference response of the output instruction sample.
- a third loss is calculated based on the resampling weights of the instruction samples and the probability of the deep learning model predicting the reference response of the output instruction sample.
- the parameters of the deep learning model are adjusted based on the third loss to obtain the deep learning model after the first round of iterative training.
- the resampling weights of the instruction samples correspond to the task type of the instruction samples; instruction samples of the same task type have the same resampling weights.
- the resampling weights for different task types can be different.
- a larger resampling weight can be configured, while a smaller resampling weight can be configured for other simpler task types.
- the principle of calculating the third loss is consistent with the principle of calculating the first loss in step S203 above, as detailed in the relevant content of the aforementioned embodiments, and will not be repeated here.
- the server uses autoregressive causal language modeling loss to train the deep learning model.
- the server inputs the instruction samples from the first round of training set into the deep learning model for response prediction, determines the probability of the deep learning model predicting the reference response of the output instruction sample; calculates the fourth loss based on the probability of the deep learning model predicting the reference response of the output instruction sample; adjusts the parameters of the deep learning model based on the fourth loss to obtain the deep learning model after the first round of iterative training.
- the principle of calculating the fourth loss is consistent with the principle of calculating the second loss in step S203 above, as detailed in the relevant content of the aforementioned embodiments, and will not be repeated here.
- the server uses a reference model to select instruction samples from the previous training set whose model fitting difficulty meets preset conditions. These samples serve as seed instructions for the current round.
- the training set for the current round is constructed based on these seed instructions, and the deep learning model obtained from the previous round of training continues iteratively based on this training set. See steps S704-S707 for details until iterative training continues. After training, the trained deep learning model is used as the target model for the completed training.
- Step S704 Based on the deep learning model obtained from the previous iteration, instruction samples whose model fitting difficulty meets preset conditions are selected from the previous training set using a reference model, and these are used as seed instructions for the current round.
- the predicted response of the instruction samples in the previous training set is generated using the deep learning model obtained from the previous iteration; a reference response of the instruction samples is generated using the reference model; the model fitting difficulty of the instruction samples is determined based on the quality difference between the predicted response and the reference response; and instruction samples whose model fitting difficulty meets preset conditions are selected from the previous training set, and these are used as seed instructions for the current round.
- Step S705 Construct the training set for this round based on the seed instruction of this round. In this step, based on the seed instruction and the task type of the seed instruction, similar instructions of the same task type are generated as instruction samples for this round.
- the proportion of instruction samples of each task type in the instruction samples of this round matches the preset task proportion.
- a reference response for the instruction samples of this round is generated through a reference model.
- a training set containing the instruction samples of this round and the reference response of the instruction samples of this round is constructed as the training set for this round.
- the specific implementation principle of this step is similar to that of step S202 above, which expands the seed instruction to generate multiple instruction samples and constructs a training set containing instruction samples. The difference is that the seed instruction on which the training set is constructed in this step is the seed instruction of this round.
- the server can sample multiple instruction samples and reference responses from the previous training set and add them to the current training set.
- the training set includes not only challenging instructions generated in this round but also relatively simple instructions from the previous training set (relatively simple for the deep learning model after the first round of training). Exposure to relatively simple instructions helps prevent the model from catastrophically forgetting basic tasks (simple tasks other than complex and challenging ones). Specifically, based on the pre-configured proportion of newly generated instructions for each round and the number of newly generated instruction samples currently included in the current training set, multiple instruction samples and reference responses from the previous training set are sampled and added to the current training set, ensuring that the proportion of newly generated instruction samples in the current training set matches the proportion of newly generated instructions in the current round. The proportion of newly generated instructions increases progressively with each round.
- the server can set a scaling factor 'a', representing the proportion of newly generated instructions (challenging instructions generated in the current round) in each training set.
- the initial value of this scaling factor 'a' serves as the proportion of newly generated instructions in the second round.
- the scaling factor 'a' is 30%.
- the scaling factor 'a' increases by a fixed increment of 10%. Therefore, in the third round, the scaling factor 'a' becomes 30% x (1+10%), and in the fourth round, it becomes 30% x (1+10%) x (1+10%).
- the server can configure the proportion of newly generated instructions for each iteration. For example, if the proportion of newly generated instructions in the training set is 30% in the second round, and in subsequent iterations, this proportion increases by a preset increment (such as 10%, 20%, etc.). If the preset increment is 10%, the proportion of newly generated instructions in the training set is 40% in the third round, 50% in the fourth round, and so on, until the proportion of newly generated instructions in the training set increases. Once the proportion of generated instructions reaches 100%, no further increases are made.
- the server can also be configured to limit the proportion of newly generated instructions in the training set to no more than a preset maximum proportion (e.g., 100%, or 90%).
- Step S706 Based on the current training set, the deep learning model obtained from the previous iteration continues iterative training.
- the server inputs the instruction samples from the current training set into the deep learning model for response prediction, determining the probability of the deep learning model predicting the reference response of the output instruction sample. Based on the resampling weights of the instruction samples and the probability of the deep learning model predicting the reference response of the output instruction sample, a fifth loss is calculated; the parameters of the deep learning model are adjusted based on the fifth loss to obtain the trained target model.
- the resampling weights of the instruction samples correspond to the task type of the instruction samples; instruction samples of the same task type have the same resampling weights.
- the resampling weights corresponding to different task types can be different. For more complex and challenging task types, such as mathematical, logical reasoning, and programming-related tasks, a larger resampling weight can be configured, while a smaller resampling weight is configured for other simpler task types.
- the autoregressive causal language modeling loss used in existing instruction fine-tuning resampling weights are added to similar instruction samples for different tasks, and the losses of different instruction samples are weighted, so that the model has task awareness during instruction fine-tuning and can pay more attention to more complex and challenging tasks, thereby improving the model's ability to handle more complex and challenging tasks.
- the fifth loss can be calculated using the following formula (3) based on the resampling weight of the instruction sample and the probability of the reference response of the deep learning model predicting the output instruction sample: logPr[y £
- L5 (0) represents the fifth loss
- 1 represents the parameters of the deep learning model.
- D represents the training set of the rth round, and r represents the round number.
- ( ⁇ , ⁇ ) represents any instruction sample-reference response pair in the training set, ⁇ represents the instruction sample, and y £ represents the reference response of the instruction sample ⁇ .
- T(%i, yt) represents the task type of the instruction sample-reference response pair (%i, ⁇ ), and Pr[T(x £ , y £ )] represents the resampling weight corresponding to the task type T(x £ , y £ ).
- x £ , 1] represents the probability that the deep learning model predicts the reference response ⁇ based on the instruction sample ⁇ , that is, the probability that the deep learning model predicts the correct prediction result ⁇ corresponding to ⁇ .
- the server can directly use the autoregressive causal language modeling loss as the sixth loss to train the deep learning model.
- the server inputs the instruction samples from the current training set into the deep learning model for response prediction, determining the probability of the deep learning model predicting the reference response of the output instruction sample; based on the probability of the deep learning model predicting the reference response of the output instruction sample, the sixth loss is calculated; the parameters of the deep learning model are adjusted based on the sixth loss to obtain the target model after training.
- Step S707 Determine whether the iterative training termination condition is met.
- the iterative training termination condition can be model performance convergence, reaching the maximum number of iterations, etc., and can be configured according to the actual application scenario and experience; no specific limitation is made here.
- Step S708 Use the trained deep learning model as the target model after training.
- the method in the first round of iterative training, uses a fine-tuned model obtained by fine-tuning the deep learning model using an existing instruction dataset.
- a reference model is used to select seed instructions from the instruction dataset that meet preset conditions for model fitting difficulty, which serve as the seed instructions for the first round.
- a training set for the first round is constructed based on these seed instructions, and the initial deep learning model is trained using this training set.
- a reference model is used to select instruction samples from the previous round's training set that meet preset conditions for model fitting difficulty, which serve as the seed instructions for the current round.
- a training set for the current round is constructed based on these seed instructions, and the deep learning model obtained in the previous round is iteratively trained using this training set. This continues until the iterative training ends, and the trained deep learning model is used as the target model.
- FIG 8 is a framework diagram of the model training provided in this embodiment.
- a deep learning model fine-tuned using the instruction dataset
- a reference response is generated using a reference model.
- task-specific prompts such as those containing thought chains or detailed problem-solving instructions can be used to improve the quality of the generated reference responses.
- a referee model is used to filter and refine the instructions, obtaining challenging instructions and constructing a training set. Specifically, the referee model evaluates the predicted and reference responses, determining the model fitting difficulty based on the difference in quality evaluation values between the predicted and reference responses, and selecting seed instructions with higher model fitting difficulty. Further, the reference model constructs challenging instruction data based on the seed instructions, and a training set containing challenging instruction data is built. The instruction data for each task type in the constructed training set matches the preset task ratio. Furthermore, in subsequent rounds of iterative training, a reference model is used to select seed instructions with higher model fitting difficulty from the training set of the previous round (round r-1 as shown in the figure).
- the training set for the current round (round r as shown in the figure) is constructed based on the selected seed instructions. Task resampling is then used to ensure that the resampled training sets match the preset task ratio.
- the deep learning model is trained using the training set of this round. Additionally, when constructing the training set for this round, some instruction data is extracted from the training set of the previous round and added to the current training set. The proportion of newly generated instructions in each round's training set increases progressively, resulting in a continuously increasing proportion of challenging instructions generated in the current round's training set used in subsequent rounds, while the proportion of instructions retained from the previous round's training set continuously decreases.
- FIG 9 is a flowchart of a data processing method provided in an exemplary embodiment of this disclosure.
- the execution entity in this embodiment is the server in the aforementioned system architecture.
- the specific steps of this method are as follows: Step S901: Receive the call request from the terminal device for the target model.
- the call request includes input instructions.
- the server provides the API of the trained target model to the terminal device.
- the terminal device can send a call request for the target model to the server based on the API of the target model.
- This call request includes user input information.
- the server receives the call request for the target model sent by the terminal device and extracts the user's input instructions from the call request.
- the input instructions can be instructions for natural language processing tasks such as text summarization, translation, and question answering; or speech-to-text tasks; or image-to-text tasks; or natural language understanding (NLU) tasks such as sentiment analysis; or other types of tasks. No specific limitations are made here.
- Step S902 Input the input instructions into the target model and generate a response result for the input instructions through the target model.
- the target model is trained as follows: Seed instructions that meet preset fitting difficulty criteria are selected from the existing instruction dataset using a reference model. Multiple instruction samples are generated based on these seed instructions, and a training set containing these instruction samples is constructed.
- Step S903 Return the response result of the input command to the terminal device. After generating the response result of the input command, the server returns the response result of the input command to the terminal device. The terminal device displays the response result of the input command to the user.
- the target model is trained and obtained in the following way: Using a reference model, commands that meet the preset conditions for model fitting difficulty are selected from the existing command dataset. Commands with high model fitting difficulty and challenges can be selected from the command dataset as seed commands. Based on the seed commands, multiple similar command samples are generated to obtain more challenging command samples.
- FIG 10 is a schematic diagram of the structure of a server provided in an embodiment of this disclosure.
- the server includes a memory 1001 and a processor 1002.
- the memory 1001 stores computer execution instructions and can be configured to store various other data to support operations on the server.
- the processor 1002 is communicatively connected to the memory 1001 and executes the computer execution instructions stored in the memory 1001 to implement the technical solutions provided in any of the above method embodiments. Its specific functions and the technical effects it can achieve are similar and will not be repeated here.
- the server also includes other components such as a firewall 1003, a load balancer 1004, a communication component 1005, and a power supply component 1006.
- Figure 10 only schematically shows some components and does not imply that the server only includes the components shown in Figure 10.
- Figure 10 only uses a cloud server deployed in the cloud as an example for illustrative purposes; the server can also be deployed locally, and this embodiment does not specifically limit its deployment.
- This disclosure also provides a computer-readable storage medium storing computer-executable instructions.
- This disclosure also provides a computer program product, including a computer program that, when executed by a processor, implements the methods of any of the foregoing embodiments.
- the computer program is stored in a readable storage medium.
- At least one processor of a server can read the computer program from the readable storage medium.
- At least one processor executes the computer program, causing the server to perform the technical solutions provided by any of the foregoing method embodiments.
- Specific functions and achievable technical effects are not detailed here.
- This disclosure provides a chip, including a processing module and a communication interface. The processing module can execute the technical solutions of the server in the foregoing method embodiments.
- the chip further includes a storage module (e.g., a memory).
- the storage module stores instructions, and the processing module executes the instructions stored in the storage module. Execution of the instructions stored in the storage module causes the processing module to perform the technical solutions provided by any of the foregoing method embodiments.
- the integrated modules implemented as software functional modules described above can be stored in a computer-readable storage medium.
- the aforementioned software functional modules are stored in a storage medium and include several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) or processor to execute some steps of the methods of the various embodiments of this disclosure.
- the aforementioned processor may be a Central Processing Unit (CPU), a Graphics Processing Unit (GPU), or other general-purpose processors, Digital Signal Processors (DSPs), Application Specific Integrated Circuits (ASICs), etc.
- a general-purpose processor may be a microprocessor or any conventional processor.
- the steps of the methods disclosed in the application can be directly implemented by a hardware processor, or implemented by a combination of hardware and software modules in at least one processor.
- the memory may include high-speed random access memory (RAM), and may also include non-volatile memory, such as at least one disk storage device, and may also be a USB flash drive, external hard drive, read-only memory, etc. Disks or optical discs, etc.
- the aforementioned storage can be object storage (OSS).
- This storage can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as Static Random Access Memory (SRAM), Electrically Erasable Programmable Read Only Memory (EEPROM), Erasable Programmable Read Only Memory (EPROM), Programmable Read Only Memory (PROM), Read Only Memory (ROM), magnetic storage, flash memory, disks, or optical discs.
- SRAM Static Random Access Memory
- EEPROM Electrically Erasable Programmable Read Only Memory
- EPROM Erasable Programmable Read Only Memory
- PROM Programmable Read Only Memory
- ROM Read Only Memory
- magnetic storage flash memory, disks, or optical discs.
- the aforementioned communication components are configured to facilitate wired or wireless communication between the device containing the communication components and other devices.
- the device housing the communication component can access wireless networks based on communication standards, such as mobile hotspots (WiFi), 2G, 3G, 4G/Long Term Evolution (LTE), 5G, or combinations thereof.
- WiFi mobile hotspots
- the communication component receives broadcast signals or broadcast-related information from an external broadcast management system via a broadcast channel.
- the communication component also includes a Near Field Communication (NFC) module to facilitate short-range communication.
- NFC Near Field Communication
- the NFC module may be based on Radio Frequency Identification (RFID), infrared, Ultra Wide Band (UWB), Bluetooth, and other technologies.
- RFID Radio Frequency Identification
- UWB Ultra Wide Band
- Bluetooth Bluetooth
- the aforementioned power supply component provides power to various components of the device housing the power supply component.
- the power supply component may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power to the device housing the power supply component.
- the aforementioned storage medium can be implemented using any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic storage, flash memory, magnetic disk, or optical disk.
- SRAM static random access memory
- EEPROM electrically erasable programmable read-only memory
- EPROM erasable programmable read-only memory
- PROM programmable read-only memory
- ROM read-only memory
- magnetic storage flash memory
- flash memory magnetic disk
- optical disk optical disk.
- the storage medium can be any available medium accessible to a general-purpose or special-purpose computer.
- An exemplary storage medium is coupled to a processor, enabling the processor to read information from and write information to the storage medium.
- the storage medium can also be a component of the processor.
- the processor and storage medium can exist as discrete components in an electronic device or host device.
- the terms "comprising,””including,” or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus.
- an element defined by the phrase “comprising a" does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element.
- the order of the embodiments described above is merely descriptive and does not represent the superiority or inferiority of the embodiments.
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- Data Mining & Analysis (AREA)
- Evolutionary Computation (AREA)
- Artificial Intelligence (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Software Systems (AREA)
- Computational Linguistics (AREA)
- Life Sciences & Earth Sciences (AREA)
- Mathematical Physics (AREA)
- Computing Systems (AREA)
- Biomedical Technology (AREA)
- Molecular Biology (AREA)
- General Health & Medical Sciences (AREA)
- Biophysics (AREA)
- Health & Medical Sciences (AREA)
- Bioinformatics & Cheminformatics (AREA)
- Bioinformatics & Computational Biology (AREA)
- Computer Vision & Pattern Recognition (AREA)
- Evolutionary Biology (AREA)
- Machine Translation (AREA)
Abstract
本公开提供一种模型训练、数据处理的方法及设备。本公开的方法,通过借助参考模型从已有的指令数据集中筛选出模型拟合难度满足预设条件的指令,可以从指令数据集中筛选出模型拟合难度较高的、具有挑战性的指令,作为种子指令;基于种子指令扩展生成多个相似的指令样本,即可获得更多具有挑战性的指令样本,并构建包含指令样本及指令样本的参考响应的训练集,可以借助参考模型基于已有的指令数据集实现知识蒸馏,获得包含更高质量指令数据的训练集;进一步地,使用该训练集训练深度学习模型,可以提升深度学习模型处理更复杂和具有挑战性的任务的能力,提升训练完成后目标模型的性能。
Description
模型训练、 数据处理的方法及设备 本公开要求申请号为 202410732637. 3 的中国专利申请的优先权, 该中国专利申请于 2024年 06月 05 日提交中国专利局, 申请名称为 “模型训练、 数据处理的方法及设备” , 其全部内容通过引用结合在本公开中。 技术领域 本公开涉及计算机技术, 尤其涉及一种模型训练、 数据处理的方法及设备。 背景技术 大型语言模型有在指令微调后泛化到训练集中没有的任务的能力。 指令微调通过在指 令数据集监督微调 (SFT) 语言模型模型来实现预训练的语言模型与用户偏好对齐。 与传 统的特定任务微调不同, 指令微调利用远少于预训练的数据来训练模型的内在能力以及在 预训练阶段积累的广泛知识。 随着强大的专有语言模型的出现和使用, 各种知识蒸馋 (Knowledge Distillation, 简称 KD ) 方法已经被提出。 采用知识蒸馋技术, 可以借助参数较大能力较高的语言模型 (作为 教师模型) 来对参数量更小的语言模型 (作为学生模型) 进行指令微调, 从而将教师模型 的知识和能力压缩到更小、 更高效的学生模型中, 使得参数量更小的模型能在保持相对较 高性能的同时, 降低对计算资源的需求。 现有指令微调 方法获得的深度学习模型, 在处理更复杂和具有挑战性的任务 (例如逻 辑推理、 代码生成等任务) 时会遇到困难, 性能较差。 发明内容 本公开提供一种模型训练、 数据处理的方法及设备, 用以解决深度学习模型在处理更 复杂和具有挑战性的任务时会遇到困难, 性能较差的问题。 第一方面, 本公开提供一种模型训练的方法, 包括: 借助参考模型, 从已有的指令数 据集中筛选出模型拟合难度满足预设条件的指令, 作为种子指令; 基于所述种子指令扩展 生成多个指令样本, 并构建包含所述指令样本及所述指令样本的参考响应的训练集; 使用 所述训练集训练深度学习模型, 获得训练完成的目标模型。 第二方面, 本公开提供一种数据处理方法, 包括: 接收端侧设备对所述目标模型的调 用请求, 所述调用请求包含输入指令; 将所述输入指令输入所述目标模型, 通过所述目标 模型生成所述输入指令的响应结果, 所述目标模型通过如下方式训练得到: 借助参考模型 从已有的指令数据集中筛选出模型拟合难度满足预设条件的种子指令, 基于所述种子指令 扩展生成多个指令样本, 并构建包含所述指令样本及所述指令样本的参考响应的训练集, 使用所述训练集训练深度学习模型, 获得训练完成的目标模型; 向所述端侧设备返回所述 输入指令的响应结果。 第三方面, 本公开提供一种服务器, 包括: 至少一个处理器; 以及与所述至少一个处 理器通信连接的存储器 ; 其中, 所述存储器存储有可被所述至少一个处理器执行的指令, 所述指令被所述至少一个处理器执行, 以使所述服务器执行如前述任一方面所提供的方法。 第四方面, 本公开提供一种计算机可读存储介质, 所述计算机可读存储介质中存储有 计算机执行指令, 当处理器执行所述计算机执行指令时, 实现如前述任一方面所提供的方 法。 第五方面, 本公开提供一种计算机程序产品, 包括计算机程序, 该计算机程序被处理 器执行时实现如前述任一方面所提供的方法。 本公开提供的模型训练、 数据处理的方法及设备, 通过借助参考模型从已有的指令数
据集中筛选出模型拟合难度满足预设条件的指令, 可以从指令数据集中筛选出模型拟合难 度较高的、 具有挑战性的指令, 作为种子指令; 基于种子指令扩展生成多个相似的指令样 本, 即可获得更多具有挑战性的指令样本, 并构建包含指令样本及指令样本的参考响应的 训练集, 可以借助参考模型基于已有的指令数据集实现知识蒸馋, 获得更高质量的具有挑 战性指令数据的训练集; 进一步地, 使用该训练集训练深度学习模型, 可以提升深度学习 模型处理更复杂和具有挑战性的任务的能力, 提升训练完成后目标模型的性能。 附图说明 此处 的附图被并入说明书中并构成本公开的一部分, 示出了符合本公开的实施例, 并 与说明书一起用于解释本公开的原理。 图 1为本公开所适用的一示例系统架构的示意图; 图 2为本公开一示例性实施例提供的神经网络模型训练方法流程图; 图 3为本公开一示例性实施例提供的筛选种子指令的流程图; 图 4为本公开一示例性实施例提供的基于种子指令构建训练集的流程图; 图 5为本公开一示例性实施例提供的已有指令数据集中各任务类型占比的示意图; 图 6为本公开一示例性实施例提供的各任务类型的预设任务比例的示意图; 图 7为本公开另一示例性实施例提供的模型训练的方法流程图; 图 8为本公开一示例性实施例提供的模型训练的框架图; 图 9为本公开一示例性实施例提供的数据处理方法流程图; 图 10为本公开实施例提供的一种服务器的结构示意图。 通过上述 附图, 已示出本公开明确的实施例, 后文中将有更详细的描述。 这些附图和 文字描述并不是为了通过任何方式限制本公开构思的范围, 而是通过参考特定实施例为本 领域技术人员说明本公开的概念。 具体实施方式 这里将详 细地对示例性实施例进行说明, 其示例表示在附图中。 下面的描述涉及附图 时, 除非另有表示, 不同附图中的相同数字表示相同或相似的要素。 以下示例性实施例中 所描述的实施方式并不代表与本公开相一致的所有实施方式。 相反, 它们仅是与如所附权 利要求书中所详述的、 本公开的一些方面相一致的装置和方法的例子。 需要说明的是, 本公开所涉及的用户信息 (包括但不限于用户设备信息、 用户属性信 息等) 和数据 (包括但不限于用于分析的数据、 存储的数据、 展示的数据等) , 均为经用 户授权或者经过各方充分授权的信息和数据, 并且相关数据的收集、 使用和处理需要遵守 相关法律法规和标准, 并提供有相应的操作入口, 供用户选择授权或者拒绝。 首先对本公开所涉及的名词进行解释: 指令微调 : 也称为指令调优, 使用用户指令数据和参考回复 (响应) 来微调大语言模 型, 使得大语言模型生成更符合用户偏好的回复。 思维链: 通过引导语言模型模拟人类思维过程中的推理步骤来提升其解决推理问题的 能力, 如算术或常识推理问题。 课程 学习 (Curriculum Learning) : 是一种机器学习训练策略, 旨在通过让模型先学习 简单概念再逐步过渡到复杂概念, 来提高模型的学习效率和最终性能。
Alpaca数据集: 是一种基于人工手写的种子数据和模型扩写生成的开源指令微调数据 集, 涵盖了语法、 时尚、 数学、 食物等多个任务和领域。 视 觉问答任务: 根据输入的图像和问题, 从输入图像的视觉信息中确定问题的答案。 图像描述任务: 生成输入图像的描述文本。
视 觉蕴涵任务: 预测输入图像和文本在语义上的相关性, 即蕴涵、 中性或矛盾。 指代表达 与理解任务: 根据输入文本定位输入图像中与输入文本对应的图像区域。 图像生成任务: 基于输入的描述文本生成图像。 基 于文本的情感分类任务: 预测输入文本的情感分类信息。 文本摘要任务: 生成输入文本的摘要信息。 多模态任务: 是指输入输出数据涉及图像和文本等多种模态数据的下游任务, 例如视 觉问答任务、 图像描述任务、 视觉蕴涵任务、 指代表达与理解任务、 图像生成任务等。 多模态预训练模型: 是指输入输出数据涉及图像和文本等多种模态数据的预训练模型, 经过微调训练后可以应用于多模态任务处理。 预训练语 言模型: 对大规模语言模型 (Large Language Model, 简称 LLM) 进行预训 练后得到的预训练模型。 大模型是指具有大规模模型参数的深度学习模型, 通常包含上亿、 上百亿、 甚至上千 亿的模型参数。 大模型又可以称为基石模型 /基础模型 (Foundation Model, 简称 FM) , 通 过大规模无标注的语料进行大模型的预训练, 产出亿级以上参数的预训练模型, 这种模型 能适应广泛的下游任务, 模型具有较好的泛化能力, 例如大规模语言模型(Large Language Model, 简称 LLM) 、 多模态预训练模型 (Multi-modal Pre- training Model) 等。 大模型在实际应用时, 仅需少量样本对预训练模型进行微调即可应用于不同的任务中, 大模型可以广泛应用于自然语言处理 (Natural Language Processing, 简称 NLP) 、 计算机 视觉等领域, 具体可以应用于如视觉问答 (Visual Question Answering, 简称 VQA) 、 图像 描述 (Image Caption, 简称 IC) 、 图像生成等计算机视觉领域任务, 以及基于文本的情感 分类、 文本摘要生成、 机器翻译等自然语言处理领域任务, 大模型主要的应用场景包括数 字助理、 智能机器人、 搜索、 在线教育、 办公软件、 电子商务、 智能设计等。 有研 究表明, 增强指令数据的多样性和复杂性可以提高模型性能。 但对于具有不同容 量和参数的模型, 指令数据的较佳复杂性仍是一个未解决的问题。 现有方案试图通过使用 句子嵌入来最大化数据多样性。 但这种方法并未解决模型能力不平衡的问题。 使用这些方 法微调的深度学习模型有时在处理更复杂和具有挑战性的任务 (例如逻辑推理、 代码生成 等任务) 时会遇到困难, 性能较差, 生成响应结果的质量较低。 为了解决前述技术问题, 本公开提供一种模型训练的方法, 借助参考模型从已有的指 令数据集中筛选出模型拟合难度满足预设条件的指令, 可以从指令数据集中筛选出模型拟 合难度较高的、 具有挑战性的指令, 作为种子指令; 基于种子指令扩展生成多个相似的指 令样本, 即可获得更多具有挑战性的指令样本, 并构建包含指令样本及指令样本的参考响 应的训练集, 可以借助参考模型基于已有的指令数据集实现知识蒸馋, 获得具有挑战性指 令数据的训练集; 进一步地, 使用该训练集训练深度学习模型, 可以提升深度学习模型处 理更复杂和具有挑战性的任务的能力, 提升训练完成后目标模型的性能。 其 中, 指令的模型拟合难度是指模型训练过程中学习 (或拟合) 得到处理该指令的能 力的难易程度, 指令的模型拟合难度越高, 说明模型越不容易学习 (或拟合) 得到处理该 指令的能力, 也即模型越难拟合得到生成该指令的正确答复的能力。 图 1为本公开所适用的一示例系统架构的示意图。 如图 1所示, 该系统架构包括服务 器和端侧设备。 其中, 服务器与端侧设备之间具有可通信的通信链路, 能够实现服务器与 端侧设备间的通信连接。 服 务器是部署在云端或本地的具有计算能力的设备, 例如云集群等。 服务器负责获取 和存储待训练的深度学习模型, 以及已有的指令数据集。 基于已有的指令数据集, 服务器 可以借助参考模型从已有的指令数据集中筛选出模型拟合难度满足预设条件的指令, 作为 种子指令, 基于种子指令扩展生成多个指令样本, 并构建包含指令样本的训练集; 使用训
练集训练深度学习模型, 获得训练完成的目标模型。 其 中, 深度学习模型可以是基于图像、 语音、 文本中至少一种模态的信息进行自然语 言处理的深度学习模型, 例如各类人机交互模型, 实现文本到文本的生成任务 (如文本摘 要、翻译、 问答) 的模型, 语音转文本的模型 (如语音识别模型) , 图像转文本的模型 (如 OCR 模型、 图像摘要) , 情绪分析等自然语音理解 (NLU)模型, 等等。 深度学习模型具 体可以是轻量化模型、 预训练模型、 或者参数量相对较少的大语言模型、 多模态语言模型 等, 本实施例此处对于深度学习模型不做具体限定。 参考模型是指具有 强大能力的预训练模型, 相较于深度学习模型, 参考模型具有更大 规模的参数量, 并且推理能力更强, 具体可以根据目标模型的具体应用场景, 选择应用于 相同场景下的具有强大能力的预训练模型作为参考模型。 例如大规模或超大规模的语言模 型等。 参考模型可以运行在另一云服务器上 (图 1中未示出) , 图 1中用于训练深度学习 模型的服务器可以通过参考模型的程序编程接口(Application Program Interface,简称 API), 调用参考模型, 使用参考模型的推理能力。 另外, 参考模型也可以运行在图 1中用于训练 深度学习模型的服务器上, 此处对此不做具体限定。 端侧设备 可以是运行下游应用的电子设备, 具体可以为具有网络通信功能、 运算功能 以及信息显示功能的硬件设备, 其包括但不限于智能手机、 平板电脑、 台式电脑、 本地服 务器、 云端服务器等。 端侧设备运行下游应用时需要使用目标模型的推理能力。 端侧设备 运行的下游应用可以实现文本摘要、 翻译、 问答等自然语言处理任务, 或者语音转文本任 务, 或者图像转文本任务, 或者情绪分析等自然语音理解 (NLU) 任务等。 在实现下游应 用的功能时, 需要使用目标模型的推理能力,通过目标模型基于给定的输入信息进行推理, 生成输入信息的响应结果。 端侧设备基于输入信息的响应结果实现下游应用后续的处理逻 辑。 基 于图 1所示的系统架构, 端侧设备向服务器发送用户的输入信息。 服务器接收输入 信息, 将输入信息输入至目标模型, 通过目标模型生成输入信息的响应结果, 并向端侧设 备返回输入信息的响应结果。 端侧设备接收服务器返回的输入信息的响应结果, 基于输入 信息的响应结果, 继续执行后续的处理逻辑。 示例性地 , 服务器可以将训练后的目标模型的 API提供给端侧设备。 端侧设备可以基 于目标模型的 API 向服务器发送目标模型的调用请求, 该调用请求包含用户的输入信息。 服务器接收端侧设备发送的对目标模型的调用请求, 并从调用请求中提取用户的输入信息, 通过目标模型生成输出信息的响应结果, 并向端侧设备返回响应结果。 另外, 服务器还可以将训练后的目标模型 (或训练后目标模型的参数) 提供给端侧设 备, 端侧设备可以在本地使用训练后的目标模型, 基于目标模型的推理能力实现具体的下 游应用的任务, 如文本摘要、 翻译、 问答等自然语言处理任务, 或者语音转文本任务, 或 者图像转文本任务, 或者情绪分析等自然语音理解 (NLU) 任务等。 当然, 训练后的目标 模型还可以应用于其他如人工智能领域的任务, 此处不做具体限定。 下面以具体地实施例对本公开的技术方案 以及本公开的技术方案如何解决上述技术 问题进行详细说明。 下面这几个具体的实施例可以相互结合, 对于相同或相似的概念或过 程可能在某些实施例中不再赘述。 下面将结合附图, 对本公开的实施例进行描述。 图 2为本公开一示例性实施例提供的神经网络模型训练方法流程图。 本实施例的执行 主体为前述系统架构中的服务器。 本实施例的方法, 借助参考模型对已有的指令数据集进 行知识蒸馋, 以构建指令数据的模型拟合难度较高的训练集, 该训练集包括的指令数据因 模型拟合难度较高而具有挑战性。 进一步地, 使用知识蒸馋得到的具有挑战性的训练集训 练深度学习模型, 获得目标模型, 可以提升目标模型处理更复杂和具有挑战性的任务的能 力, 提升目标模型的性能。 如 图 2所示, 该方法具体步骤如下:
步骤 S201、借助参考模型, 从已有的指令数据集中筛选出模型拟合难度满足预设条件 的指令, 作为种子指令。 其 中, 已有的指令数据集可以来源于公开的指令数据集,例如 Alpaca数据集、Guanaco 数据集等开源数据集, 或现有任意用于大语言模型指令微调的数据集。 已有的指令数据集 也可以来源于用户通过端侧设备提供的私有数据集, 或者利用大模型自动构建的指令数据, 本实施例此处不做具体限定。 指令数据集通常包括指令-响应对, 指令 -响应对包括指令及 指令的响应。 本实施例中, 用于知识蒸馋的参考模型可以由相关技术人员根据用户需求进行配置指 定, 也可以由用户通过端侧设备指定。 参考模型是指具有强大能力的预训练模型, 相较于 深度学习模型, 参考模型具有更大规模的参数量, 并且推理能力更强, 具体可以根据目标 模型的具体应用场景, 选择应用于相同场景下的具有强大能力的预训练模型作为参考模型 O 例如大规模或超大规模的语言模型等。 待训练 的深度学习模型可以由用户通过端侧设备指定, 也可以由相关技术人员根据用 户需求进行配置指定。 深度学习模型可以是基于图像、 语音、 文本中至少一种模态的信息 进行自然语言处理的深度学习模型, 例如各类人机交互模型, 实现文本到文本的生成任务 (如文本摘要、 翻译、 问答) 的模型, 语音转文本的模型 (如语音识别模型) , 图像转文 本的模型 (如 OCR模型、 图像摘要) , 情绪分析等自然语音理解 (NLU)模型, 等等。 深 度学习模型具体可以是轻量化模型、 预训练模型、 或者参数量相对较少的大模型、 多模态 语言模型等, 本实施例此处对于深度学习模型不做具体限定。 在一示例场景 中, 用户需要对深度学习模型进行指令微调时, 通过端侧设备向服务器 发送模型训练请求, 该模型训练请求中包含了待训练的深度学习模型和参考模型的信息。 响应于端侧设备的模型训练请求, 服务器基于待训练的深度学习模型和参考模型的信息, 可以确定端侧设备指定的参考模型和待训练的深度学习模型。 其中, 深度学习模型的参数 量少于参考模型的参数量。 另一示例场景中, 为了降低计算成本, 服务器端需要使用轻量化的深度学习模型替代 大模型向端侧设备提供服务。 服务器可以将大模型作为参考模型, 借助参考模型进行知识 蒸馋,训练轻量化的深度学习模型,使得训练完成的目标模型在保持相对较高性能的同时, 降低对计算资源的需求。 服务器使用训练完成的目标模型代替大模型向端侧设备提供服务。 该 步骤中, 借助参考模型对指令数据集中指令的模型拟合难度进行测评, 并从已有的 指令数据集中筛选出模型拟合难度满足预设条件的指令, 获得具有挑战性的指令, 作为用 于构建具有挑战性的训练集的种子指令。 其中, 预设条件可以为模型拟合难度大于或等于 难度阈值& 基于该预设条件可以筛选出模型拟合难度较大的挑战性指令。 其中难度阈值 6 可以根据指令响应质量测评值的取值范围并结合实际应用场景进行配置和调整, 例如指令 响应质量测评值的取值范围可以为 [1,10] , 难度阈值 6可以取值为 2或 3等, 此处不做具体 限定。 另一可选实施例中, 预设条件可以是指令的任务类型属于预定义的任务类型集合。 该 任务类型集合中包含多种模型拟合难度较大、 具体挑战性的任务类型, 包括但不限于: 数 学、 逻辑推理、 编程相关任务。 该步骤中, 服务器借助参考模型判断已有的指令数据集中 指令的任务类型, 并从指令数据集中筛选出任务类型属于预定义的任务类型集合的指令, 作为模型拟合难度满足预设条件的指令, 获得具有挑战性的指令, 作为用于构建具有挑战 性的训练集的种子指令。 步骤 S202、基于种子指令扩展生成多个指令样本, 并构建包含指令样本及指令样本的 参考响应的训练集。 在 筛选出模型拟合难度较大的种子指令之后, 服务器借助参考模型, 基于种子指令扩 展生成多个类似的指令, 作为构建训练集的指令样本。
进一 步地, 服务器借助参考模型生成指令样本的参考响应, 得到指令样本及指令样本 的参考响应组成的指令样本-参考响应对, 构建包含指令样本及指令样本的参考响应(即指 令样本一参考响应对) 的训练集。 该训练集可用于指令微调, 并且包含具体挑战性的指令数 据。 其中, 指令样本的参考响应是对指令样本的一个高质量的响应信息, 可以理解为是指 令样本的正确响应、 或标注的响应。 步骤 S203、 使用训练集训练深度学习模型, 获得训练完成的目标模型。 在获得具有挑战性的训练集之后 , 使用该训练集对深度学习模型进行指令微调, 获得 训练完成的目标模型。 该 步骤的一种可选实施方式中, 服务器将训练集中的指令样本输入深度学习模型进行 响应预测, 确定深度学习模型预测输出指令样本的参考响应的概率。 根据指令样本的重采 样权重和深度学习模型预测输出指令样本的参考响应的概率, 计算第一损失; 根据第一损 失调整深度学习模型的参数, 获得训练完成的目标模型。 其 中, 指令样本的重采样权重与指令样本的任务类型对应, 同一任务类型的指令样本 具有相同的重采样权重。 不同任务类型对应的重采样权重可以不同。 对于较复杂的具有挑 战性的任务类型, 如数学、 逻辑推理、 编程相关任务等任务类型, 可以配置较大的重采样 权重, 而其他较简单的任务类型则配置较小的重采样权重。 该实施 方式中, 在现有指令微调中使用的自回归因果语言建模损失的基础上, 对不同 任务类似的指令样本增加重采样权重, 对不同指令样本的损失进行加权, 使得指令微调过 程中模型具有任务感知能力, 可以更加关注较复杂的具有挑战性的任务, 从而提升模型处 理更复杂和具有挑战性的任务的能力。 示例性地 , 可以采用如下公式(1) , 根据指令样本的重采样权重和深度学习模型预测 输出指令样本的参考响应的概率, 计算第一损失: k (0) = - £3奶) eDs Pr|7(首,3)] logPr[ym,e] (1) 其 中, LJ0)表示第一损失, ①表示深度学习模型的参数。久表示基于种子指令构建的 训练集。 (着 ,力)表示训练集久中的任意指令样本-参考响应对, 着表示指令样本, 勿表示指 令样本着的参考响应。 T(首 ,力)表示
Pr[T(x£,y£)] 表示任务类型 T(%i,yi)对应的重采样权重。 Pr[yJ%i, ①]表示深度学习模型基于指令样本着预 测得到其参考响应力的概率, 也即深度学习模型预测得到着对应的正确预测结果勿的概率。 该 步骤的另一种可选实施方式中, 服务器将训练集中的指令样本输入深度学习模型进 行响应预测, 确定深度学习模型预测输出指令样本的参考响应的概率; 根据深度学习模型 预测输出指令样本的参考响应的概率, 计算第二损失; 根据第二损失调整深度学习模型的 参数, 获得训练完成的目标模型。 该实施 方式中, 服务器直接使用自回归因果语言建模损失作为第二损失, 来训练深度 学习模型。 示例性地, 可以采用如下公式 (2) , 根据深度学习模型预测输出指令样本的参 考响应的概率, 计算第二损失:
logPr[y£|x£, <I)] (2) 其 中, L2(0)表示第二损失, 公式 (2) 中其他字符的含义与公式 (1) 中一致, 此处不 再赘述。 本实施例 中, 对使用训练集训练深度学习模型所使用的训练策略, 包括但不限于所选 择的优化算法、 学习率等, 可以根据实际应用场景进行配置和调整, 此处不做具体限定。
在得 到训练后的目标模型之后, 服务器可以向端侧设备提供目标模型。 示例性地 , 在获得训练完成的目标模型之后, 服务器可以向端侧设备提供目标模型的 调用接口。 端侧设备可以基于目标模型的调用接口向服务器发送目标模型的调用请求, 该 调用请求包含用户的输入信息。 服务器接收端侧设备发送的对目标模型的调用请求, 并从 调用请求中提取用户的输入信息, 通过目标模型生成输出信息的响应结果, 并向端侧设备 返回响应结果。 示例性地 , 在端侧设备存储有深度学习模型的结构的情况下, 在获得训练完成的目标 模型之后, 服务器可以向端侧设备发送目标模型的参数。 端侧设备根据目标模型的参数, 初始化本地存储的深度学习模型的参数, 得到训练完成的目标模型。 示例性地 , 服务器还可以向端侧设备发送目标模型的下载信息。 端侧设备根据接收到 的目标模型的下载信息, 将预训练的目标模型下载到本地。 服 务器将通过知识蒸馋得到的目标模型提供给端侧设备, 使得端侧设备可以将目标模 型存储到本地, 端侧设备可以在本地使用目标模型的推理能力。 本实施例的方案, 服务器借助参考模型从已有的指令数据集中筛选出模型拟合难度满 足预设条件的指令,可以从指令数据集中筛选出模型拟合难度较高的、具有挑战性的指令, 作为种子指令; 基于种子指令扩展生成多个相似的指令样本, 即可获得更多具有挑战性的 指令样本, 并构建包含指令样本及指令样本的参考响应的训练集, 通过借助参考模型基于 已有的指令数据集实现知识蒸馋, 获得具有挑战性指令数据的训练集; 使用该训练集训练 深度学习模型, 可以提升深度学习模型处理更复杂和具有挑战性的任务的能力, 提升训练 完成后目标模型的性能。 在一 可选实施例中, 前述步骤 S201中,借助参考模型, 从已有的指令数据集中筛选出 拟合难度满足预设条件的指令, 作为种子指令, 具体可以采用如下方式实现: 使用指令数 据集对深度学习模型进行微调, 获得微调模型; 通过微调模型生成指令数据集中指令的预 测响应,通过参考模型生成指令的参考响应;根据指令的预测响应与参考响应的质量差异, 确定指令的模型拟合难度 (Model Fitting Difficulty, 简称 MFD) , 并筛选出模型拟合难度 满足预设条件的指令, 作为种子指令。 其 中, 预设条件可以为模型拟合难度大于或等于难度阈值& 难度阈值 6可以根据指令 响应质量测评值的取值范围并结合实际应用场景进行配置和调整, 例如指令响应质量测评 值的取值范围可以为 [1,10], 难度阈值 6可以取值为 2或 3等, 此处不做具体限定。 图 3为本公开实施例提供的筛选种子指令的流程图。 如图 3所示, 借助参考模型, 从 已有的指令数据集中筛选出拟合难度满足预设条件的种子指令的具体流程如下: 步骤 S300、 获取已有的指令数据集。 本实施例中, 已有的指令数据集可以来源于公开的指令数据集, 例如 Alpaca数据集、 Guanaco数据集等开源数据集, 或现有任意用于大语言模型指令微调的数据集。 已有的指 令数据集也可以来源于用户通过端侧设备提供的私有数据集, 或者利用大模型自动构建的 指令数据, 本实施例此处不做具体限定。指令数据集通常包括指令-响应对, 指令-响应对包 括指令及指令的响应。 步骤 S301、 使用指令数据集对深度学习模型进行微调, 获得微调模型。 该 步骤中, 使用已有的指令数据集对深度学习模型 (用 S表示) 进行指令微调, 获得 微调模型 (用 So表示) 。 指令微调的过程可以采用现有任意一种指令微调方法实现, 此处 不做具体限定。 步骤 S302、 通过微调模型生成指令数据集中指令的预测响应。 该 步骤中, 通过使用指令数据集指令微调后的微调模型 So生成指令数据集中指令的响 应, 称为预测响应。 该步骤旨在评估深度学习模型在不经过复杂训练的情况下, 从指令数
据集中学习的基本能力。 步骤 S3O3、 通过参考模型生成指令数据集中指令的参考响应。 该 步骤中, 通过参考模型生成指令数据集中指令的响应, 称为参考响应。 步骤 S304、通过裁判模型对指令的预测响应和参考响应进行质量测评, 获得预测响应 的质量测评值和参考响应的质量测评值。 其 中, 裁判模型用于对微调模型 S °生成的预测响应和参考模型生成的参考响应的响应 质量进行测评, 获得预测响应的质量测评值和参考响应的质量测评值。 其中, 裁判模型可 以使用现有的任意一种实现指令的响应质量测评的算法 /模型实现,例如裁判模型可以使用 大语言模型 LLM 实现。 示例性地 , 获取预先配置的质量测评提示信息, 将指令、 指令的预测响应和参考响应 分别填充到质量测评提示信息后, 输入裁判模型。 通过裁判模型基于质量测评提示信息的 提示, 对指令的预测响应和参考响应进行评分, 得到指令的预测响应和参考响应的质量测 评值 (即得分) 。 另外, 质量测评提示信息还可以定义进行质量测评的其他规则或要求, 例如输出格式、 给出评估依据/理由等, 此处不做具体限定。 例如 , 下面为一个质量测评提示信息的示例:
“你是一个测评人工智能助手回答质量的助手, 基于给定的用户指令: {Instruction}, 智能助手 1的回答: {answer」}, 智能助手 2的回答: {answer_2}, 我们希望您对两个人工 智能助手的在响应上面给定的用户指令方面的性 能提供反馈。 请对他们的回答的有用性、 相关性、 准确性和详细程度进行评分。每个智能助手都会得到一个在 1到 10间的得分, 其 中分数越高表示整体表现越好。 请首先对您的评估进行全面解释, 避免任何潜在的偏见, 并确保回答的顺序不会影响您的判断。 然后, 在两行中分别输出智能助手 1和智能助手 2 的得分。 输出格式如下: 评估依据 : 〈此处为您的评估说明〉 智 能助手 1的得分: VScorel > 智 能助手 2的得分: VScore2>" 。 其 中, {Instruction}表示待填充的指令, {answer_l}和{answer_2}表示待填充的预测响 应和参考响应。 〈此处为您的评估说明〉表示遍判模型输出的评估依据 (理由) , VScorel > 表示裁 判模型输 出的{answer」}的质量测评值, V Score2 >表示裁判模型输出的 { answer_2}的质量测评值。 该示例中, 约束了每个响应的质量测评值在区间[1,10]内取值。 基于该实例的质量测评提示信 息, 裁判模型通过一次推理可以一次性获得指令的两个 响应 (包括预测响应和参考响应) 的质量测评值, 并且预测响应和参考响应的质量测评值 更具有可比性。 在 另一个可选实施例中, 可以利用裁判模型根据指令及指令的预测响应, 对指令的预 测响应进行测评, 获得指令的预测响应的质量测评值; 通过裁判模型根据指令及指令的参 考响应, 对指令的参考响应进行测评, 获得指令的参考响应的质量测评值。 通过分别对指 令的预测响应、 指令的参考响应进行独立的质量测评, 获得两个响应的质量测评值。 步骤 S305、根据指令的参考响应的质量测评值与预测响应的质量测评值的差值, 确定 指令的模型拟合难度。 在获得指令的参考响应的质量测评值与预测响应的质量测评值之后, 将指令的参考响 应作为基准, 计算指令的参考响应的质量测评值与预测响应的质量测评值的差值。 该差值 越大,说明相较于参考模型生成的参考响应, 由深度学习模型生成的预测响应的质量越差。 该差值越小 (大于 0) , 说明深度学习模型生成的预测响应的质量越接近参考模型生成的 参考响应的质量, 但仍然比参考模型生成的参考响应的质量差。 当该差值小于 0时, 说明 深度学习模型生成的预测响应的质量已超越参考模型生成的参考响应的质量。
进一 步地, 将该指令的参考响应的质量测评值与预测响应的质量测评值的差值, 作为 指令的模型拟合难度 (MFD) o 可选地, 还可以将该指令的参考响应的质量测评值与预测响应的质量测评值的差值乘 以一个缩放系数后, 作为指令的模型拟合难度 (MFD) o 其中缩放系数可以根据实际应用 需求和经验值进行配置, 此处不做具体限定。 本实施例中, 为了构建一个具有挑战性的种子指令, 引入了模型拟合难度 (MFD) 这 一测评指标, 用于衡量指令的模型拟合难度, 也即模型学习获得正确响应该指令的能力的 难度。 通过前述步骤 S304-S305, 根据指令的预测响应与参考响应的质量差异, 确定指令 的模型拟合难度。 基于指令的模型拟合难度 (MFD) , 能够从已有的指令数据集中有选择 性地筛选出具有挑战性的种子指令。 步骤 S306、从指令数据集中筛选出模型拟合难度满足预设条件的指令,作为种子指令。 本实施例中, 为了筛选获得具有挑战性的指令, 配置一个预设条件作为筛选条件。 在 获得指令数据集中各指令的模型拟合难度 (MFD) 之后, 该步骤中, 根据预设条件, 从指 令数据集中筛选出模型拟合难度 (MFD) 满足预设条件的指令, 作为种子指令。 其 中,预设条件可以为模型拟合难度大于或等于难度阈值&基于该预设条件可以筛选 出模型拟合难度较大的挑战性指令。 其中难度阈值 6可以根据指令响应质量测评值的取值 范围并结合实 际应用场景进行配置和调整, 例如指令响应质量测评值的取值范围可以为 [1,10], 难度阈值 6可以取值为 2或 3等, 此处不做具体限定。 另一可选实施例中, 预设条件可以是指令的任务类型属于预定义的任务类型集合。 该 任务类型集合中包含多种模型拟合难度较大、 具体挑战性的任务类型, 包括但不限于: 数 学、 逻辑推理、 编程相关任务。 该步骤中, 服务器借助参考模型判断已有的指令数据集中 指令的任务类型, 并从指令数据集中筛选出任务类型属于预定义的任务类型集合的指令, 作为模型拟合难度满足预设条件的指令, 获得具有挑战性的指令, 作为用于构建具有挑战 性的训练集的种子指令。 本实施例的方法, 通过使用已有的指令数据集对深度学习模型进行微调后的微调模型, 生成指令数据集中指令的预测响应, 并通过参考模型生成指令数据集中指令的参考响应; 通过裁判模型测评获得指令的参考响应和预测相应的指令测评值, 基于指令的参考响应和 预测相应的指令测评值的差值确定指令的模型拟合难度 (MFD) , 作为衡量指令的模型拟 合难度和挑战性的指标, 利用模型拟合难度 (MFD) 可以筛选出具有挑战性的种子指令, 以构建具有挑战性的训练集, 可以鼓励深度学习模型处理更具挑战性的任务, 从而避免了 模型对简单任务产生偏好的可能性, 提升深度学习模型处理更复杂和具有挑战性的任务的 能力, 提升训练完成后目标模型的性能。 图 4为本公开一示例性实施例提供的基于种子指令构建训练集的流程图。 在一可选实 施例中, 基于筛选出的具有挑战性的种子指令, 进行策略性地指令蒸馋, 并构建训练集, 以确保训练集中不同任务类型的指令分布的均衡性, 使得模型在各任务类型上的性能更加 均衡。 本实施例中, 如图 4所示, 前述步骤 S202中, 基于种子指令扩展生成多个指令样本, 并构建包含指令样本的训练集, 具体可以采用如下方式实现: 步骤 S2021、 通过参考模型, 基于种子指令及种子指令的任务类型, 生成相同任务类 型的相似指令及响应, 作为指令样本及指令样本的参考响应。 本实施例中, 利用参考模型基于种子指令扩展生成与种子指令的相似指令。 该相似指 令与种子指令的任务类型相同, 并且在指令长度、 难度上也与种子指令相当。 示例性地 , 获取预先配置的指令生成提示信息, 将种子指令、 种子指令的任务类型分 别填充到指令生成提示信息后, 输入参考模型。 通过参考模型基于指令生成提示信息的提 示, 生成与种子指令相似的全新指令。 要求相似指令与种子指令的任务类型相同, 并且在
指令长度、 难度上也与种子指令相当。 另外, 指令生成提示信息还可以定义待生成的指令 样本的长度、 难度、 内容等各方面的约束信息, 此处不做具体限定。 例如 , 下面为一个指令生成提示信息的示例:
“您扮演指令创造者的角色。您的目标是从给定的种子指令中汲取灵感,创建全新的 指令。此新指令应具有与给定的种子指令相同的任务类型: [{task_type}] o新指令的长度和 难度应与给定种子指令相似。 新指令的内容应与给定种子指令不同。 新指令必须合理, 并 且必须被人类理解和响应。 给定的种子指令 : {Instruction} 新指令 : 〈instruction〉” 。 其 中, {Instruction}表示待填充的种子指令。 {task_type}表示待填充的任务类型, 是种 子指令的任务类型。 〈instruction>表示参考模型生成的新指令。 进一 步地, 在获得生成的指令样本之后, 利用参考模型生成指令样本的参考响应。 示例性地 , 获取预先配置的响应生成提示信息, 将指令样本填充到响应生成提示信息 后, 输入参考模型。 通过参考模型基于响应生成提示信息的提示, 生成指令样本的参考响 应。 响应生成提示信息可以使用现有任一问答模型的提示信息, 此处不做具体限定。 例如 , 响应生成提示信息的一个示例如下:
“你是一个智能助手, 能够对给定的指令做出响应。 给定的指令 : {Instruction} 你的响应 : < answer> ” 。 其 中,{Instruction}表示待填充的指令样本,〈answer〉表示参考模型生成的参考响应。 在一可选实施例 中, 在生成指令样本时, 要求参考模型生成的指令样本的任务比例符 合一个均衡的配额, 也即要求生成的指令样本中各任务类型的指令样本所占比例与预设的 任务比例相匹配。 经研 究发现, 语言模型在数学、 逻辑推理和编程这三类任务上的表现, 会一直随着指 令微调数据量的增长而增长, 而在其他任务上的表现在指令微调数据达到一定数据量后增 长放缓。 因此在一可选实施例中, 配置各任务类型的任务比例, 其中增大了在数学、 逻辑 推理和编程等关键任务类型的比例。 示例性地 , 图 5提供了已有指令数据集中各任务类型的指令数据的比例的示意图, 图 6提供了配置的各任务类型的任务比例示意图。图 5和图 6中横坐标表示指令数据的数量, 纵坐标表示指令数据的不同任务类型。 如图 5中所示, 在已有指令数据集中, 占较大比重 的指令数据属于常识 (Common-Sense) 、 科技 (Technology) 、 语言 (Grammar) 、 文学 (Literature) 及其他 (Others) 等简单任务, 而数学 (Math) 、 逻辑推理 (Reasoning) 、 代码 (包括代码生成 (Code Generation) 和代码调试 (Code Debug) ) 等具有挑战性的任 务类型的指令数据相对较少。 相较于图 5所示的已有指令数据集中各任务类型的比例, 本 实施了的方 法中配置的各任务类型的任务比例如 图 6 所示, 数学 (Math) 、 逻辑推理 (Reasoning) 、 代码 (包括代码生成 (Code Generation) 和代码调试 (Code Debug) ) 等 具有挑战性的任务类型的指令数据为主, 增大了在数学、 逻辑推理和编程等关键任务类型 的比例, 而其他各类简单任务的指令数据占比较少。 示例性地, 各任务类型的任务比例可 以配置如下: 数学、 逻辑推理、 代码生成和代码调试的比例为 0.167:0.167:0.083:0.083, 这 四种任务类型共占 50%, 其余任务平均分配剩余 50%的配额。 各任务类型以及各任务类型 的任务比例可以根据实际应用场景的需求进行配置, 此处不做具体限定。 需要说明的是, 图 5和图 6中除了上述提及的数学 (Math)、逻辑推理 (Reasoning)、 代码 (包括代码生成 (Code Generation) 和代码调试 (Code Debug) ) 等具有挑战性的任 务类型, 还包括写作 (Writing) 、 计算机科学 (Computer Science) 、 法律 (Law) 、 医药
(Medicine) 、 艺术 (Art) 、 音乐 (Music) 等等多种任务类型, 图 5和图 6中其他任务类 型可能不完全一致。 至于指令数据集中除数学 (Math)、逻辑推理 (Reasoning)、代码 (包 括代码生成 (Code Generation) 和代码调试 (Code Debug) ) 等具有挑战性的任务类型之 外, 所覆盖的任务类型越全面越好, 至于还包括其他哪些任务类型的指令数据, 可以根据 实际需要配置, 不会影响本方案的技术效果。 图 5 和图 6 强调数学 (Math) 、 逻辑推理 (Reasoning) 、 代码 (包括代码生成 (Code Generation) 和代码调试 (Code Debug) ) 等 具有挑战性的任务类型的指令数据的占比, 而图 5和图 6中其他未做说明的任务类型, 可 以参见现有公开数据集中对应任务类型的指令数据, 此处不再 —说 明。 可选地 , 服务器可以根据预设的任务比例, 配置各任务类型的重采样权重, 根据各任 务类型的重采样权重, 从种子指令中采样各任务类型的种子指令, 并根据采样到的种子指 令, 生成相同任务类型的相似指令, 作为指令样本。 基于任一种子指令一次生成的相似指令的数量相 同, 对于重采样权重越大的任务类型, 对应任务类型的种子指令被采样的次数越 多, 生成对应任务类型的指令样本的数量越多。 由此可以控制构建的训练集中各任务类型的指令数据的比例。 可选地 , 服务器可以随机采样各任务类型的种子指令生成对应任务类型的指令样本; 构建包含所生成的所有指令样本的训练集。 然后, 根据预设的任务比例, 删除训练集中的 部分指令样本, 使得调整后训练集中各任务类型的指令数据的比例与预设的任务比例匹配 O 在一可选实施例 中, 通过参考模型生成指令样本的参考响应时, 服务器根据指令样本 的任务类型, 获取对应任务类型的提示信息, 不同任务类型的提示信息可以不同。 任一任 务类型的提示信息包含响应对应任务类型的指令的详细要求, 用于提示参考模型针对对应 任务类型生成更好的参考响应。 对于 复杂的任务类型, 例如数学、 逻辑推理、 代码生成或代码调试等。 任一复杂任务 类型的提示信息还可以包含思维链 (Chain of Thought, 检测 CoT) , 思维链将对应任务类 型指令的推理过程拆分成多个步骤, 以提示参考模型分步骤推理生成指令样本的参考响应, 可以提升生成的参考响应的质量。 进一 步地, 通过参考模型, 根据对应任务类型的提示信息生成指令样本的参考响应。 示例性地 , 代码生成类的提示信息的一个简单示例如下:
“你是一个智能助手, 能够对给定的任务指令做出响应。 请提供一个带有注释的代码 片段, 然后进行解释。 任 务指令: {Instruction} 你的响应 : < answer > ” 。 其 中,{Instruction}表示待填充的指令样本,〈answer〉表示参考模型生成的参考响应。 该提示信息中 “请提供一个带有注释的代码片段, 然后进行解释说明 ”是针对代码生成任 务的特别要求, 要求生成的代码片段中给出注释, 并给出代码的解释说明。 示例性地 , 包含思维链的提示信息的一个简单示例如下:
“你是一个智能助手, 能够对给定的任务指令做出响应。 请按照如下步骤循序渐进地 思考并详细回答: 步骤 1.. ; 步骤 2.. 任 务指令: {Instruction} 你的响应 : < answer > ” 。 其 中,{Instruction}表示待填充的指令样本,〈answer〉表示参考模型生成的参考响应。 该提示信息中 “请按照如下步骤循序渐进地思考并详细回答: 步骤 1. ……; 步骤 2. …… ” 给出了思维链定义的推理步骤, 要求参考模型基于思维链定义的推理步骤循序渐进地思考 并详细回答, 也即分步骤进行推理给出参考响应。 此处仅为示例, 省略了各步骤的具体内
容, 具体步骤可以根据应用的实际任务进行配置。 本实施例中, 若指令数据集中不包含指令数据的任务类型, 可以使用参考模型对指令 进行任务分类。 示例性地, 将指令填充到任务分类提示信息后, 输入参考模型, 通过参考 模型根据任务分类提示信息的提示, 确定指令的任务类型。 任务分类提示信息用于提示参 考模型对给定指令进行任务分类, 任务分类提示信息的具体内容可以根据实际应用场景的 需求进新配置, 此处不做具体限定。 例如 , 基于图 6所示的任务类型, 任务分类提示信息的一个示例如下:
“你是一个智能助手, 能够对给定的指令进行任务类型或领域的分类, 并解释分类的 依据: 任 务类型或领域如下列表: ['Math', 'Code Generation 5 , 'Writing', 'Computer
Science\ 'Reasoning', 'Complex Format', 5 Code Debug5,
' Common-Sense,, 5 Counterf actual5, 'Multilingual', 'Roleplay',
' Biology5, ,Technology', ,Ethics',, Sport',,Law',
' Medicine5, 'Literature', 'Entertainment',,Art', 'Music',
' Toxicity', 'Economy', 'Physics', 'History', 'Chemistry',
' Philosophy', 'Health', 'Ecology', 'Grammar', 'Paraphrase', ’Others'] 指令 : {Instruction} 任 务类型: < classification> 。 其 中,{Instruction}表示待填充的指令,< classification>表示参考模型生成的参考响应。 该提示信息中任务类型的列表可以根据实际应用场景进行配置和挑战, 此处不做具体限定 O 步骤 S2022、 构建包含指令样本及指令样本的参考响应的训练集。 在获得 与预设任务比例相匹配的指令样本及指令样本的参考响应之后, 构建包含这些 指令样本及指令样本的参考响应的训练集。 本实施例的方法, 通过参考模型, 基于种子指令及种子指令的任务类型, 生成相同任 务类型的相似指令及响应, 作为指令样本及指令样本的参考响应, 基于筛选出的具有挑战 性的种子指令进行策略性地指令蒸馋, 并构建更具挑战性的训练集, 可以提升模型处理更 复杂和具有挑战性的任务的能力。 另外, 本实施例中配置预设的任务比例, 其中增大了在 数学、 逻辑推理和编程等关键任务类型的比例, 要求生成的指令样本中各任务类型的指令 样本所占比例与预设的任务比例相匹配, 以确保构建的训练集中不同任务类型的指令分布 的均衡性, 使得模型在各任务类型上的性能更加均衡, 可以提升模型的性能和指令响应质 量。 图 7为本公开另一示例性实施例提供的模型训练的方法流程图。 在前述任一实施的基 础上, 本实施例中, 在第一轮迭代训练中, 基于使用已有的指令数据集对深度学习模型进 行微调训练得到的微调模型, 借助参考模型从指令数据集中筛选出模型拟合难度满足预设 条件的种子指令, 作为第一轮的种子指令, 基于第一轮的种子指令构建第一轮的训练集, 使用第一轮的训练集训练初始的深度学习模型。 在后 续各轮迭代训练中, 基于前一轮迭代训练得到的深度学习模型, 借助参考模型从 前一轮的训练集中筛选 出模型拟合难度满足预设条件的指令样本, 作为本轮的种子指令, 基于本轮的种子指令构建本轮的训练集, 基于本轮的训练集对前一轮迭代训练得到的深度 学习模型继续进行迭代训练。 直 至迭代训练结束, 将训练得的深度学习模型作为训练完成的目标模型。 如 图 7所示, 该方法具体步骤如下: 步骤 S700、 获取已有的指令数据集。
其 中, 已有的指令数据集可以来源于公开的指令数据集,例如 Alpaca数据集、Guanaco 数据集等开源数据集, 或现有任意用于大语言模型指令微调的数据集。 已有的指令数据集 也可以来源于用户通过端侧设备提供的私有数据集, 或者利用大模型自动构建的指令数据, 本实施例此处不做具体限定。 指令数据集通常包括指令-响应对, 指令 -响应对包括指令及 指令的响应。 本实施例 中, 在第一轮迭代训练中, 基于使用已有的指令数据集对深度学习模型进行 微调训练得到的微调模型, 借助参考模型从指令数据集中筛选出模型拟合难度满足预设条 件的种子指令, 作为第一轮的种子指令, 基于第一轮的种子指令构建第一轮的训练集, 使 用第一轮的训练集训练初始的深度学习模型。 具体参见步骤 S701-S703 o 步骤 S701、借助参考模型, 从已有的指令数据集中筛选出模型拟合难度满足预设条件 的指令, 作为第一轮的种子指令。 该 步骤中, 借助参考模型, 从已有的指令数据集中筛选出模型拟合难度满足预设条件 的指令的实现原理与前述步骤 S201 的实现原理一致, 具体参见前述实施例的相关内容, 此处不再赘述。 本实施例 中, 将从已有的指令数据集中筛选出模型拟合难度满足预设条件的指令, 作 为第一轮迭代训练中使用的种子指令, 称为第一轮的种子指令。 步骤 S702、 基于第一轮的种子指令扩展生成多个指令样本, 并构建第一轮的训练集。 该 步骤的实现原理与前述步骤 S202 的实现原理一致, 具体参见前述实施例的相关内 容, 此处不再赘述。 步骤 S703、 使用第一轮的训练集训练初始的深度学习模型。 在 第一轮迭代训练的过程中, 使用第一轮的训练集对深度学习模型进行指令微调, 获 得第一轮迭代训练得到的深度学习模型。 该 步骤的一种可选实施方式中, 在现有指令微调中使用的自回归因果语言建模损失的 基础上, 对不同任务类似的指令样本增加重采样权重, 对不同指令样本的损失进行加权, 使得指令微调过程中模型具有任务感知 能力, 可以更加关注较复杂的具有挑战性的任务, 从而提升模型处理更复杂和具有挑战性的任务的能力。 具体地 , 服务器将第一轮的训练集中的指令样本输入深度学习模型进行响应预测, 确 定深度学习模型预测输出指令样本的参考响应的概率。 根据指令样本的重采样权重和深度 学习模型预测输出指令样本的参考响应的概率, 计算第三损失; 根据第三损失调整深度学 习模型的参数, 获得第一轮迭代训练后的深度学习模型。 其 中, 指令样本的重采样权重与指令样本的任务类型对应, 同一任务类型的指令样本 具有相同的重采样权重。 不同任务类型对应的重采样权重可以不同。 对于较复杂的具有挑 战性的任务类型, 如数学、 逻辑推理、 编程相关任务等任务类型, 可以配置较大的重采样 权重, 而其他较简单的任务类型则配置较小的重采样权重。 第三损失计算原理与前述步骤 S203中第一损失的计算原理一致, 具体参见前述实施例的相关内容, 此处不再赘述。 该 步骤的另一种可选实施方式中, 服务器使用自回归因果语言建模损失, 来训练深度 学习模型。 具体地, 服务器将第一轮的训练集中的指令样本输入深度学习模型进行响应预 测, 确定深度学习模型预测输出指令样本的参考响应的概率; 根据深度学习模型预测输出 指令样本的参考响应的概率, 计算第四损失; 根据第四损失调整深度学习模型的参数, 获 得第一轮迭代训练后的深度学习模型。 其中第四损失计算原理与前述步骤 S203 中第二损 失的计算原理一致, 具体参见前述实施例的相关内容, 此处不再赘述。 在 第二轮及后续各轮迭代训练过程中, 服务器基于前一轮迭代训练得到的深度学习模 型, 借助参考模型从前一轮的训练集中筛选出模型拟合难度满足预设条件的指令样本, 作 为本轮的种子指令, 基于本轮的种子指令构建本轮的训练集, 基于本轮的训练集对前一轮 迭代训练得到的深度学习模型继续进行迭代训练。 具体参见步骤 S704-S707o 直至迭代训
练结束, 将训练得的深度学习模型作为训练完成的目标模型。 步骤 S704、基于前一轮迭代训练得到的深度学习模型, 借助参考模型从前一轮的训练 集中筛选出模型拟合难度满足预设条件的指令样本, 作为本轮的种子指令。 该 步骤中, 通过前一轮迭代训练得到的深度学习模型, 生成前一轮的训练集中指令样 本的预测响应; 通过参考模型生成指令样本的参考响应; 根据指令样本的预测响应与参考 响应的质量差异, 确定指令样本的模型拟合难度; 从前一轮的训练集中筛选出模型拟合难 度满足预设条件的指令样本, 作为本轮的种子指令。 其 中, 根据指令样本的预测响应与参考响应的质量差异, 确定指令样本的模型拟合难 度, 与前述步骤 S304-S305的实现原理类似, 具体参见前实施例的相关内容, 此处不再赘 述。 其 中, 从前一轮的训练集中筛选出模型拟合难度满足预设条件的指令样本的实现原理, 与前述步骤 S306的实现原理类似, 具体参见前实施例的相关内容, 此处不再赘述。 步骤 S705、 基于本轮的种子指令构建本轮的训练集。 该 步骤中, 基于本轮的种子指令及种子指令的任务类型, 生成相同任务类型的相似指 令, 作为本轮的指令样本, 本轮的指令样本中各任务类型的指令样本所占比例与预设的任 务比例相匹配; 通过参考模型生成本轮指令样本的参考响应; 构建包含本轮的指令样本及 本轮指令样本的参考响应的训练集, 作为本轮的训练集。 该 步骤的具体实现原理与前述步骤 S202基于种子指令扩展生成多个指令样本, 并构 建包含指令样本的训练集的实现原理类型, 不同之处在于该步骤中构建训练集所基于的种 子指令是本轮的种子指令。 具体参见前述实施例的相关内容, 此处不再赘述。 本实施例 中, 服务器可以从前一轮的训练集中采样多个指令样本及指令样本的参考响 应, 添加到本轮的训练集中, 使得训练集不仅包含本轮生成的具有挑战性的指令, 还包含 前一轮的训练集中相对较简单 (对于经第一轮训练后的深度学习模型相对较简单)的指令, 通过接触相对简单的指令 以避免模型对基本任务 (除复杂的挑战性任务之外的简单任务) 的灾难性遗忘。 具体地 , 根据预先配置的各轮对应的新生成指令的配置比例, 以及本轮的训练集中当 前包含的本轮新生成的指令样本的数量, 从前一轮的训练集中采样多个指令样本及指令样 本的参考响应, 添加到本轮的训练集, 使得本轮的训练集中新生成指令样本的占比与本轮 对应的新生成指令的配置比例匹配。 其 中, 各轮对应的新生成指令的配置比例逐轮递增。 这样, 从第二轮迭代开始, 后续 每个训练迭代轮次中, 所构建的训练集中本轮生成的挑战性指令的比例会不断增加, 而保 留的前一轮训练集中的指令的比例会不断减少, 从挑战性指令占比较低的训练集逐渐过渡 到挑战性指令占比更高的训练集, 通过连续轮次的迭代训练来改善模型处理复杂的挑战性 任务时的能力。 示例性地 ,服务器可以设置一个比例因子 a, 表示各轮的训练集中新生成指令 (本轮生 成的具有挑战性的指令)的占比。该比例因子 a的初始值,作为第二轮中新生成指令的占比。 在后续各轮迭代中, 比例因子 a按照一个固定比例增量递增,也即 a(r + 1) = a(r)(l + Aa), 其中, a(r)表示第 r轮的比例因子, a(r + 1)表示第 r+1轮的比例因子, 表示固定比例增 量。 例如, 第二轮中比例因子 a为 30%, 后续各轮迭代中, 比例因子 a按照 10%的固定比例 增量递增, 那么第三轮中比例因子 a变成 30% X (1+10%), 第四轮中比例因子 a变成 30% X (l+10%) X (l+10%) . o 示例性地 , 服务器可以配置各轮迭代对应的新生成指令的配置比例。 例如, 第二轮的 训练集中新生成指令的占比为 30% , 后续各轮迭代中训练集中新生成指令的占比按照预设 增量 (如 10%、 或 20%等) 递增。 如预设增量可以为 10%, 第三轮的训练集中新生成指令 的占比为 40%, 第四轮的训练集中新生成指令的占比为 50%, 以此类推, 直至训练集中新
生成指令的占比达到 100%后不再增加。 可选地 ,服务器还可以配置训练集中新生成指令的占比不超过预设最大占比(如 100%、 或 90%等) , 其中预设最大占比可以根据实际应用场景的需要和经验值进行配置, 此处不 做具体限定。 步骤 S706、基于本轮的训练集对前一轮迭代训练得到的深度学习模型继续进行迭代训 练。 该 步骤的一种可选实施方式中, 服务器将本轮的训练集中的指令样本输入深度学习模 型进行响应预测, 确定深度学习模型预测输出指令样本的参考响应的概率。 根据指令样本 的重采样权重和深度学习模型预测输出指令样本的参考响应的概率, 计算第五损失; 根据 第五损失调整深度学习模型的参数, 获得训练完成的目标模型。 其 中, 指令样本的重采样权重与指令样本的任务类型对应, 同一任务类型的指令样本 具有相同的重采样权重。 不同任务类型对应的重采样权重可以不同。 对于较复杂的具有挑 战性的任务类型, 如数学、 逻辑推理、 编程相关任务等任务类型, 可以配置较大的重采样 权重, 而其他较简单的任务类型则配置较小的重采样权重。 该实施 方式中, 在现有指令微调中使用的自回归因果语言建模损失的基础上, 对不同 任务类似的指令样本增加重采样权重, 对不同指令样本的损失进行加权, 使得指令微调过 程中模型具有任务感知能力, 可以更加关注较复杂的具有挑战性的任务, 从而提升模型处 理更复杂和具有挑战性的任务的能力。 示例性地 , 可以采用如下公式(3) , 根据指令样本的重采样权重和深度学习模型预测 输出指令样本的参考响应的概率, 计算第五损失:
logPr [y£ |x£, <t>] (3) 其 中, L5(0)表示第五损失, ①表示深度学习模型的参数。 D,表示第 r轮的训练集, r表 示本轮的轮次。 (着 ,力)表示训练集 中的任意指令样本-参考响应对, 着表示指令样本, y£ 表示指令 样本着的参考响应。 T(%i, yt)表示指令样本 -参考响应对(%i,勿)的任务类型, Pr[T(x£, y£)]表示任务类型 T(x£,y£)对应的重采样权重。 Pr[y£|x£, ①]表示深度学习模型基于 指令样本着预测得到其参考响应为的概率, 也即深度学习模型预测得到着对应的正确预测 结果勿的概率。 该 步骤的另一种可选实施方式中, 服务器可以直接使用自回归因果语言建模损失作为 第六损失, 来训练深度学习模型。 具体地, 服务器将本轮的训练集中的指令样本输入深度 学习模型进行响应预测, 确定深度学习模型预测输出指令样本的参考响应的概率; 根据深 度学习模型预测输出指令样本的参考响应的概率, 计算第六损失; 根据第六损失调整深度 学习模型的参数, 获得训练完成的目标模型。 步骤 S707、 判断是否满足迭代训练结束条件。 其 中, 迭代训练结束条件可以是模型性能收敛、 达到最大迭代次数等, 具体可以根据 实际应用场景和经验进行配置, 此处不做具体限定。 若判断结果 为不满足迭代训练结束条件,则迭代训练未结束,循环执行步骤 S704-S707, 进行下一轮迭代训练。 若判断结果 为满足迭代训练结束条件, 则迭代训练结束, 执行步骤 S708, 将训练得到 的深度学习模型作为训练完成的目标模型。 步骤 S708、 将训练得到的深度学习模型作为训练完成的目标模型。
本实施例的方法, 在第一轮迭代训练中, 基于使用已有的指令数据集对深度学习模型 进行微调训练得到的微调模型, 借助参考模型从指令数据集中筛选出模型拟合难度满足预 设条件的种子指令,作为第一轮的种子指令,基于第一轮的种子指令构建第一轮的训练集, 使用第一轮的训练集训练初始的深度学习模型; 在后续各轮迭代训练中, 基于前一轮迭代 训练得到的深度学习模型, 借助参考模型从前一轮的训练集中筛选出模型拟合难度满足预 设条件的指令样本, 作为本轮的种子指令, 基于本轮的种子指令构建本轮的训练集, 基于 本轮的训练集对前一轮迭代训练得到的深度学习模型继续进行迭代训练; 直至迭代训练结 束, 将训练得到的深度学习模型作为训练完成的目标模型, 通过引入多轮课程规划思想, 在连续多轮迭代训练中动态调整训练集的模型拟合难度, 通过连续轮次的迭代训练来改善 模型处理复杂的挑战性任务时的能力。 图 8为本实施例提供的模型训练的框架图。 如图 8所示, 基于已有指令数据集中的指 令首, 通过深度学习模型(用指令数据集微调后的)生成指令的预测响应免, 通过参考模型 生晟指令的参考响应勿。另外,在通过参考模型生成指令的参考响应勿时, 可以使用包含思 维链的提示信息、 或者包含问题解决的详细说明等各任务类型特定的提示信息, 以改善生 成的参考响应的质量。 进 一步地, 基于指令的预测响应免和参考响应力, 借助裁判模型进行指令的筛选及蒸 馋, 获得具有挑战性的指令并构建训练集。 具体地, 通过裁判模型对指令的预测响应免和 参考响应勿进行测评, 基于指令的预测响应免和参考响应为的质量测评值的差异确定指令 的模型拟合难度, 并筛选出模型拟合难度较大的种子指令; 进一步地, 通过参考模型基于 种子指令构建具有挑战性的指令数据, 并构建包含挑战性指令数据的训练集。 所构建的训 练集中各任务类型的指令数据与预设的任务比例相匹配。 进一 步地,在后续各轮迭代训练中,借助参考模型从前一轮(如图中所示的第 r-1轮) 的训练集筛选出模型拟合难度较高的种子指令, 基于筛选的种子指令构建本轮 (如图中所 示的第 r轮) 的训练集, 并且通过任务重采样, 使得重采样后各轮训练集与预设任务比例 匹配。 使用本轮的训练集训练深度学习模型。 另外, 在构建本轮的训练集时, 还从前一轮的训练集中抽取部分指令数据添加到本轮 的训练集中, 并且各轮的训练集中新生成指令的比例逐轮递增, 使得后续各轮使用的训练 集中本轮生成的挑战性指令的比例会不断增加, 而保留的前一轮训练集中的指令的比例会 不断减少, 从挑战性指令占比较低的训练集逐渐过渡到挑战性指令占比更高的训练集, 训 练集的难度不断增加, 通过连续轮次的迭代训练来改善模型处理复杂的挑战性任务时的能 力。 图 9为本公开一示例性实施例提供的数据处理方法流程图。 本实施例的执行主体为前 述系统架构中的服务器。 如图 9所示, 该方法具体步骤如下: 步骤 S901、 接收端侧设备对目标模型的调用请求, 调用请求包含输入指令。 本实施例中, 服务器将训练后的目标模型的 API提供给端侧设备。 端侧设备可以基于 目标模型的 API向服务器发送目标模型的调用请求, 该调用请求包含用户的输入信息。 服 务器接收端侧设备发送的对目标模型的调用请求, 并从调用请求中提取用户的输入 指令。 其 中, 输入指令可以是文本摘要、 翻译、 问答等自然语言处理任务, 或者语音转文本 任务, 或者图像转文本任务, 或者情绪分析等自然语音理解 (NLU) 任务, 或其他各类任 务的指令, 此处不做具体限定。 步骤 S902、 将输入指令输入目标模型, 通过目标模型生成输入指令的响应结果。 其 中, 目标模型通过如下方式训练得到: 借助参考模型从已有的指令数据集中筛选出 模型拟合难度满足预设条件的种子指令, 基于种子指令扩展生成多个指令样本, 并构建包 含指令样本的训练集, 使用训练集训练深度学习模型, 获得训练完成的目标模型。 目标模
型的训练过程参见前述实施例, 此处不再赘述。 步骤 S903、 向端侧设备返回输入指令的响应结果。 在 生成输入指令的响应结果之后, 服务器向端侧设备返回输入指令的响应结果。 端侧 设备向用户展示输入指令的响应结果。 本实施例的方法, 目标模型是通过如下方式训练获得的: 借助参考模型从已有的指令 数据集中筛选出模型拟合难度满足预设条件的指令, 可以从指令数据集中筛选出模型拟合 难度较高的、 具有挑战性的指令, 作为种子指令; 基于种子指令扩展生成多个相似的指令 样本, 即可获得更多具有挑战性的指令样本, 并构建包含指令样本及指令样本的参考响应 的训练集, 可以借助参考模型基于已有的指令数据集实现知识蒸馋, 获得具有挑战性指令 数据的训练集; 进一步地, 使用该训练集训练深度学习模型, 可以提升深度学习模型处理 更复杂和具有挑战性的任务的能力, 提升训练完成后目标模型的性能, 可以提升生成响应 结果的质量。 图 10为本公开实施例提供的一种服务器的结构示意图。如图 10所示,该服务器包括: 存储器 1001和处理器 1002。 存储器 1001 , 用于存储计算机执行指令, 并可被配置为存储 其它各种数据以支持在服务器上的操作。 处理器 1002, 与存储器 1001通信连接, 用于执 行存储器 1001存储的计算机执行指令, 以实现上述任一方法实施例所提供的技术方案,其 具体功能和所能实现的技术效果类似, 此处不再赘述。 可选的, 如图 10所示, 该服务器还包括: 防火墙 1003、 负载均衡器 1004、 通信组件 1005、 电源组件 1006等其它组件。 图 10中仅示意性给出部分组件, 并不意味着服务器只 包括图 10所示组件。图 10中仅以服务器为部署在云端的云服务器为例进行示例性地说明, 服务器还可以部署在本地, 本实施例此处不做具体限定。 本公开实施例还提供一种计算机可读存储介质, 计算机可读存储介质中存储有计算机 执行指令, 当处理器执行计算机执行指令时, 实现前述任一实施例的方法, 具体功能和所 能实现的技术效果此处不再赘述。 本公开实施例还提供一种计算机程序产品, 包括计算机程序, 该计算机程序被处理器 执行时实现前述任一实施例的方法。 计算机程序存储在可读存储介质中, 服务器的至少一 个处理器可以从可读存储介质读取计算机程序, 至少一个处理器执行计算机程序使得服务 器执行上述任一方法实施例所提供的技术方案, 具体功能和所能实现的技术效果此处不再 赘述。 本公开实施例提供一种芯片, 包括: 处理模块与通信接口, 该处理模块能执行前述方 法实施例中服务器的技术方案。 可选的, 该芯片还包括存储模块 (如, 存储器) , 存储模 块用于存储指令, 处理模块用于执行存储模块存储的指令, 并且对存储模块中存储的指令 的执行使得处理模块执行前述任一方法实施例所提供的技术方案。 上述 以软件功能模块的形式实现的集成的模块, 可以存储在一个计算机可读取存储介 质中。 上述软件功能模块存储在一个存储介质中, 包括若干指令用以使得一台计算机设备 (可以是个人计算机, 服务器, 或者网络设备等) 或处理器执行本公开各个实施例方法的 部分步骤。 应理解 , 上述处理器可以是中央处理单元 (Central Processing Unit, 简称 CPU) 、 图 形处理器 (graphics processing unit, 简称 GPU) , 还可以是其它通用处理器、 数字信号处 理器 (Digital Signal Processor, 简称 DSP) 、 专用集成电路 (Application Specific Integrated Circuit, 简称 ASIC)等。 通用处理器可以是微处理器或者该处理器也可以是任何常规的处 理器等。 结合申请所公开的方法的步骤可以直接体现为硬件处理器执行完成, 或者用至少 一个处理器中的硬件及软件模块组合执行完成。 存储 器可能包含高速随机存取存储器 (Random Access Memory, 简称 RAM) , 也可能 还包括非易失性存储,例如至少一个磁盘存储器,还可以为 U盘、移动硬盘、只读存储器、
磁盘或光盘等。 上述存储 器可以是对象存储 (Object Storage Service, 简称 OSS)。 上述存储器可以由任 何类型的易失性或非易失性存储设备或者它们的组合实现, 如静态随机存取存储器 ( Static Random Access Memory, 简称 SRAM) , 电可擦除可编程只读存储器 (Electrically Erasable Programmable Read Only Memory, 简称 EEPROM) , 可擦除可编程只读存储器 (Erasable Programmable Read Only Memory, 简称 EPROM) , 可编程只读存储器 (Programmable Read Only Memory, 简称 PROM) , 只读存储器 (Read Only Memory, 简称 ROM) , 磁存储器, 快闪存储器, 磁盘或光盘。 上 述通信组件被配置为便于通信组件所在设备和其他 设备之间有线或无线方式的通 信。 通信组件所在设备可以接入基于通信标准的无线网络, 如移动热点 (WiFi) , 第二代 移动通信系统 (2G) 、 第三代移动通信系统 (3G) 、 第四代移动通信系统 (4G) /长期演 进 (Long Term Evolution, 简称 LTE) 、 第五代移动通信系统 (5G) 等移动通信网络, 或 它们的组合。 在一个示例性实施例中, 通信组件经由广播信道接收来自外部广播管理系统 的广播信号或广播相关信息。在一个示例性实施例中,通信组件还包括近场通信 ( Near Field Communication, 简称 NFC) 模块, 以促进短程通信。 例如, 在 NFC模块可基于射频识别 (Radio Frequency Identification, 简称 RFID)技术, 红外技术, 超宽带 (Ultra Wide Band, 简称 UWB) 技术, 蓝牙技术和其他技术来实现。 上述 电源组件, 为电源组件所在设备的各种组件提供电力。 电源组件可以包括电源管 理系统, 一个或多个电源, 及其他与为电源组件所在设备生成、 管理和分配电力相关联的 组件。 上 述存储介质可以是由任何类型的易失性或非易失性存储设备或者它们的组合实现, 如静态随机存取存储器 (SRAM) , 电可擦除可编程只读存储器 (EEPROM) , 可擦除可 编程只读存储器 (EPROM) , 可编程只读存储器 (PROM) , 只读存储器 (ROM) , 磁存 储器, 快闪存储器, 磁盘或光盘。 存储介质可以是通用或专用计算机能够存取的任何可用 介质。 一种示例性 的存储介质耦合至处理器, 从而使处理器能够从该存储介质读取信息, 且 可向该存储介质写入信息。 当然, 存储介质也可以是处理器的组成部分。 处理器和存储介 质可以位于专用集成电路中。 当然, 处理器和存储介质也可以作为分立组件存在于电子设 备或主控设备中。 需要说明的是, 在本文中, 术语 “包括” 、 “包含 ”或者其任何其他变体意在涵盖非 排他性的包含,从而使得包括一系列要素的过程、方法、物品或者装置不仅包括那些要素, 而且还包括没有明确列出的其他要素, 或者是还包括为这种过程、 方法、 物品或者装置所 固有的要素。 在没有更多限制的情况下, 由语句 “包括一个 …… " 限定的要素, 并不排除 在包括该要素的过程、 方法、 物品或者装置中还存在另外的相同要素。 上述 本公开实施例的顺序仅仅为了描述, 不代表实施例的优劣。 另外, 在上述实施例 及附图中的描述的一些流程中, 包含了按照特定顺序出现的多个操作,但是应该清楚了解, 这些操作可以不按照其在本文中出现的顺序来执行或并行执行, 仅仅是用于区分开各个不 同的操作,序号本身不代表任何的执行顺序。另外,这些流程可以包括更多或更少的操作, 并且这些操作可以按顺序执行或并行执行 。 需要说明的是, 本文中的 “第一” 、 “第二” 等描述, 是用于区分不同的消息、 设备、 模块等, 不代表先后顺序, 也不限定 “第一 "和 “第二 ”是不同的类型。 “多个 ” 的含义是两个以上, 除非另有明确具体的限定。 通过 以上的实施方式的描述, 本领域的技术人员可以清楚地了解到上述实施例方法可 借助软件加必需的通用硬件平台的方式来实现, 当然也可以通过硬件, 但很多情况下前者 是更佳的实施方式。 基于这样的理解, 本公开的技术方案本质上或者说对现有技术做出贡 献的部分可 以以软件产品的形式体现出来, 该计算机软件产品存储在一个存储介质 (如 ROM/RAM, 磁碟、 光盘) 中, 包括若干指令用以使得一台终端设备 (可以是手机, 计算
机, 服务器, 空调器, 或者网络设备等) 执行本公开各个实施例的方法。 本领域技术人 员在考虑说明书及实践这里公开的发明后, 将容易想到本公开的其它实 施方案。 本公开旨在涵盖本公开的任何变型、 用途或者适应性变化, 这些变型、 用途或者 适应性变化遵循本公开 的一般性原理并包括本公开未公开的本技术领域 中的公知常识或 惯用技术手段。 以上仅为本公开的优选实施例, 并非因此限制本公开的专利范围, 凡是利用本公开说 明书及附图内容所作的等效结构或等效流程变换, 或直接或间接运用在其他相关的技术领 域, 均同理包括在本公开的专利保护范围内。
Claims
1、 一种模型训练的方法, 其中, 包括: 借助参考模型 , 从已有的指令数据集中筛选出模型拟合难度满足预设条件的指令, 作 为种子指令; 基 于所述种子指令扩展生成多个指令样本, 并构建包含所述指令样本及所述指令样本 的参考响应的训练集; 使 用所述训练集训练深度学习模型, 获得训练完成的目标模型。
2、 根据权利要求 1所述的方法, 其中, 所述借助参考模型, 从已有的指令数据集中筛 选出拟合难度满足预设条件的指令, 作为种子指令, 包括: 使 用所述指令数据集对所述深度学习模型进行微调, 获得微调模型; 通过所述微调模型 生成所述指令数据集中指令的预测响应; 通过参考模型 生成所述指令的参考响应; 根据所述指令 的预测响应与参考响应的质量差异, 确定所述指令的模型拟合难度, 并 筛选出模型拟合难度满足预设条件的指令, 作为种子指令。
3、根据权利要求 2所述的方法, 其中, 所述根据所述指令的预测响应与参考响应的质 量差异, 确定所述指令的模型拟合难度, 包括: 通过裁判模型对所述指令 的预测响应和参考响应进行质量测评, 获得所述预测响应的 质量测评值和所述参考响应的质量测评值; 根据所述指令 的参考响应的质量测评值与所述预测响应的质量测评值的差值, 确定所 述指令的模型拟合难度。
4、根据权利要求 1-3中任一项所述的方法, 其中, 所述基于所述种子指令扩展生成多 个指令样本, 并构建包含所述指令样本及所述指令样本的参考响应的训练集, 包括: 通过参考模型 , 基于所述种子指令及所述种子指令的任务类型, 生成相同任务类型的 相似指令及响应, 作为指令样本及指令样本的参考响应, 生成的指令样本中各任务类型的 指令样本所占比例与预设的任务比例相匹配; 构建 包含所述指令样本及所述指令样本的参考响应的训练集。
5、根据权利要求 4所述的方法, 其中, 所述基于所述种子指令及所述种子指令的任务 类型, 生成相同任务类型的相似指令, 作为指令样本, 包括: 根据预设 的任务比例, 配置各任务类型的重采样权重; 根据各任 务类型的重采样权重, 从所述种子指令中采样各任务类型的种子指令, 并根 据采样到的种子指令, 生成相同任务类型的相似指令, 作为指令样本。
6、根据权利要求 4或 5所述的方法, 其中, 所述通过参考模型生成所述指令样本的参 考响应, 包括: 根据所述指令样 本的任务类型, 获取对应任务类型的提示信息, 所述对应任务类型的 提示信息包含思维链, 所述思维链用于提示参考模型分步骤推理生成所述指令样本的参考 响应; 通过参考模型 , 根据所述对应任务类型的提示信息分步骤推理生成所述指令样本的参 考响应。
7、根据权利要求 1-6中任一项所述的方法, 其中, 所述使用所述训练集训练深度学习 模型, 获得训练完成的目标模型, 包括: 将所述训练集 中的指令样本输入深度学习模型进行响应预测, 确定所述深度学习模型 预测输出所述指令样本的参考响应的概率;
根据 所述指令样本的重采样权重和所述深度学 习模型预测输出所述指令样本的参考 响应的概率, 计算第一损失; 根据所述 第一损失调整所述深度学习模型的参数, 获得训练完成的目标模型。
8、 根据权利要求 1-7中任一项所述的方法, 其中, 还包括: 在 第一轮迭代训练中, 基于使用已有的指令数据集对所述深度学习模型进行微调训练 得到的微调模型, 借助参考模型从所述指令数据集中筛选出模型拟合难度满足预设条件的 种子指令, 作为第一轮的种子指令, 基于第一轮的种子指令构建第一轮的训练集, 使用第 一轮的训练集训练初始的深度学习模型; 在后续各轮迭代训练 中, 基于前一轮迭代训练得到的深度学习模型, 借助参考模型从 前一轮的训练集中筛选出模型拟合难度满足预设 条件的指令样本, 作为本轮的种子指令, 基于本轮的种子指令构建本轮的训练集, 基于本轮的训练集对前一轮迭代训练得到的深度 学习模型继续进行迭代训练; 直至迭代训练结束 , 将训练得到的深度学习模型作为训练完成的目标模型。
9、 根据权利要求 8 所述的方法, 其中, 所述基于前一轮迭代训练得到的深度学习模 型, 借助参考模型从前一轮的训练集中筛选出模型拟合难度满足预设条件的指令, 作为本 轮的种子指令, 包括: 通 过前一轮迭代训练得到的深度学习模型生成前一轮 的训练集中指令样本的预测响 应; 通过参考模型生成所述指令样本的参考响应 ; 根据所述指令样本的预测响应与参考响应的质量差异, 确定所述指令样本的模型拟合 难度; 从前一轮的训练集 中筛选出模型拟合难度满足预设条件的指令样本, 作为本轮的种子 指令。
10、 根据权利要求 8或 9所述的方法, 其中, 所述基于本轮的种子指令构建本轮的训 练集, 包括: 基于本轮的种子指令及种子指令的任 务类型, 生成相同任务类型的相似指令, 作为本 轮的指令样本, 本轮的指令样本中各任务类型的指令样本所占比例与预设的任务比例相匹 配; 通过参考模型生成本轮指令样本的参考响应 ; 构建 包含本轮的指令样本及本轮指令样本的参考响应的训练集, 作为本轮的训练集; 从前一轮的训练集 中采样多个指令样本及指令样本的参考响应, 添加到本轮的训练集 中。
11、根据权利要求 10所述的方法, 其中, 所述从前一轮的训练集中采样多个指令样本 及指令样本的参考响应, 添加到本轮的训练集中, 包括: 根据预先配置的各轮对应的新生成指令的配置 比例, 以及本轮的训练集中当前包含的 本轮新生成的指令样本的数量, 从前一轮的训练集中采样多个指令样本及指令样本的参考 响应, 添加到本轮的训练集, 使得本轮的训练集中新生成指令样本的占比与本轮对应的新 生成指令的配置比例匹配; 其 中, 各轮对应的新生成指令的配置比例逐轮递增。
12、 根据权利要求 1-11 中任一项所述的方法, 其中, 还包括: 响应于端侧设备的模型训练请求, 确定所述端侧设备指定的参考模型和待训练的深度 学习模型, 所述深度学习模型的参数量少于所述参考模型的参数量。
13、根据权利要求 1-12中任一项所述的方法, 其中, 获得训练完成的目标模型之后,
还包括: 向端侧设备提供所述目标模型的调用接口; 或者 , 向端侧设备发送所述目标模型的参数; 或者 , 向端侧设备发送所述目标模型的下载信息。
14、 一种数据处理方法, 其中, 包括: 接收端侧设备对 目标模型的调用请求, 所述调用请求包含输入指令; 将所述输入指令输入所述 目标模型, 通过所述目标模型生成所述输入指令的响应结果, 所述目标模型通过如下方式训练得到: 借助参考模型从已有的指令数据集中筛选出模型拟 合难度满足预设条件的种子指令, 基于所述种子指令扩展生成多个指令样本, 并构建包含 所述指令样本及所述指令样本的参考响应的训练集 , 使用所述训练集训练深度学习模型, 获得训练完成的目标模型; 向所述端侧设备返回所述输入指令的响应结果。
15、 一种服务器, 其中, 包括: 至 少一个处理器; 以及 与所述至少一个处理器通信连接的存储器; 其 中, 所述存储器存储有可被所述至少一个处理器执行的指令, 所述指令被所述至少 一个处理器执行, 以使所述服务器执行权利要求 1-14任一项所述的方法。
16、 一种计算机可读存储介质, 其中, 所述计算机可读存储介质中存储有计算机执行 指令, 当处理器执行所述计算机执行指令时, 实现如权利要求 1-14任一项所述的方法。
17、 一种计算机程序产品, 包括计算机程序, 其中, 该计算机程序被处理器执行时实 现如权利要求 1-14任一项所述的方法。
Applications Claiming Priority (2)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202410732637.3 | 2024-06-05 | ||
| CN202410732637.3A CN121072671A (zh) | 2024-06-05 | 2024-06-05 | 模型训练、数据处理的方法及设备 |
Publications (1)
| Publication Number | Publication Date |
|---|---|
| WO2025253201A1 true WO2025253201A1 (zh) | 2025-12-11 |
Family
ID=97835296
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| PCT/IB2025/054029 Pending WO2025253201A1 (zh) | 2024-06-05 | 2025-04-17 | 模型训练、数据处理的方法及设备 |
Country Status (2)
| Country | Link |
|---|---|
| CN (1) | CN121072671A (zh) |
| WO (1) | WO2025253201A1 (zh) |
Cited By (1)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN121765122A (zh) * | 2026-03-02 | 2026-03-31 | 浙江大学 | 一种基于智能模型的数据生成方法、装置、设备及产品 |
Citations (5)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN113221903A (zh) * | 2021-05-11 | 2021-08-06 | 中国科学院自动化研究所 | 跨域自适应语义分割方法及系统 |
| CN117171325A (zh) * | 2023-09-18 | 2023-12-05 | 杭州阿里云飞天信息技术有限公司 | 任务处理方法及服务器 |
| CN117272011A (zh) * | 2023-09-28 | 2023-12-22 | 北京百度网讯科技有限公司 | 模型测评方法、装置、电子设备和存储介质 |
| CN117667202A (zh) * | 2023-12-05 | 2024-03-08 | 新大陆数字技术股份有限公司 | 一种基于llm自动生成指令数据集的方法 |
| CN118095424A (zh) * | 2024-01-09 | 2024-05-28 | 浙江阿里巴巴机器人有限公司 | 人机交互模型对齐、人机交互的方法、设备及程序产品 |
-
2024
- 2024-06-05 CN CN202410732637.3A patent/CN121072671A/zh active Pending
-
2025
- 2025-04-17 WO PCT/IB2025/054029 patent/WO2025253201A1/zh active Pending
Patent Citations (5)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN113221903A (zh) * | 2021-05-11 | 2021-08-06 | 中国科学院自动化研究所 | 跨域自适应语义分割方法及系统 |
| CN117171325A (zh) * | 2023-09-18 | 2023-12-05 | 杭州阿里云飞天信息技术有限公司 | 任务处理方法及服务器 |
| CN117272011A (zh) * | 2023-09-28 | 2023-12-22 | 北京百度网讯科技有限公司 | 模型测评方法、装置、电子设备和存储介质 |
| CN117667202A (zh) * | 2023-12-05 | 2024-03-08 | 新大陆数字技术股份有限公司 | 一种基于llm自动生成指令数据集的方法 |
| CN118095424A (zh) * | 2024-01-09 | 2024-05-28 | 浙江阿里巴巴机器人有限公司 | 人机交互模型对齐、人机交互的方法、设备及程序产品 |
Non-Patent Citations (2)
| Title |
|---|
| LI MING, ZHANG YONG, LI ZHITAO, CHEN JIUHAI, CHEN LICHANG, CHENG NING, WANG JIANZONG, ZHOU TIANYI, XIAO JING: "From Quantity to Quality: Boosting LLM Performance with Self-Guided Data Selection for Instruction Tuning", ARXIV, 6 April 2024 (2024-04-06), pages 1 - 34, XP093385309, Retrieved from the Internet <URL:https://arxiv.org/pdf/2308.12032> [retrieved on 20250722], DOI: 10.48550/arXiv.2308.12032 * |
| YIZHONG WANG; YEGANEH KORDI; SWAROOP MISHRA; ALISA LIU; NOAH A. SMITH; DANIEL KHASHABI; HANNANEH HAJISHIRZI: "Self-Instruct: Aligning Language Models with Self-Generated Instructions", ARXIV.ORG, 25 May 2023 (2023-05-25), pages 1 - 23, XP091519515 * |
Cited By (1)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN121765122A (zh) * | 2026-03-02 | 2026-03-31 | 浙江大学 | 一种基于智能模型的数据生成方法、装置、设备及产品 |
Also Published As
| Publication number | Publication date |
|---|---|
| CN121072671A (zh) | 2025-12-05 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| JP2023031322A (ja) | 問答処理方法、問答モデルのトレーニング方法、装置、電子機器、記憶媒体及びコンピュータプログラム | |
| US11321534B2 (en) | Conversation space artifact generation using natural language processing, machine learning, and ontology-based techniques | |
| CN107908803A (zh) | 问答交互的响应方法及装置、存储介质、终端 | |
| US11900222B1 (en) | Efficient machine learning model architecture selection | |
| CN107741976A (zh) | 智能应答方法、装置、介质和电子设备 | |
| CN112115244B (zh) | 对话交互方法、装置、存储介质及电子设备 | |
| WO2017186050A1 (zh) | 人机智能问答系统的断句识别方法和装置 | |
| US20190347068A1 (en) | Personal history recall | |
| US20250181622A1 (en) | Method and system for dialogue data generation and processing | |
| CN118886519A (zh) | 模型训练方法、数据处理方法、电子设备及存储介质 | |
| CN118070072A (zh) | 基于人工智能的问题处理方法、装置、设备及存储介质 | |
| CN120764690A (zh) | 基于混合专家模型的请求处理方法、装置、设备及介质 | |
| CN111651989A (zh) | 命名实体识别方法和装置、存储介质及电子装置 | |
| Wang et al. | Text reasoning chain extraction for multi-hop question answering | |
| CN118095424A (zh) | 人机交互模型对齐、人机交互的方法、设备及程序产品 | |
| CN116662527A (zh) | 用于生成学习资源的方法及相关产品 | |
| CN113407806B (zh) | 网络结构搜索方法、装置、设备及计算机可读存储介质 | |
| CN119416748B (zh) | 基于大模型的评论信息生成方法、装置、电子设备及存储介质 | |
| CN119557397B (zh) | 问答方法和装置 | |
| CN121072671A (zh) | 模型训练、数据处理的方法及设备 | |
| CN120747672A (zh) | 一种大模型的训练方法、装置、设备以及存储介质 | |
| WO2025241513A1 (zh) | 文本生成方法、装置及系统、计算设备、可读存储介质 | |
| CN119474255A (zh) | 一种提供保险咨询服务的方法、装置、设备及存储介质 | |
| CN118585624A (zh) | 问答方法和装置 | |
| CN119202265A (zh) | 基于大语言模型构建营销垂类模型的方法、装置以及存储介质 |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| 121 | Ep: the epo has been informed by wipo that ep was designated in this application |
Ref document number: 25819365 Country of ref document: EP Kind code of ref document: A1 |