Model-based task processing method, model training method and electronic equipment

By combining the unprepared data and supervised instruction data into a sample data set, the natural language processing model continues to be pre -training, solving the problem of poor model performance and low training efficiency in existing technologies, and achieved more efficient model training And more accurate text generation results.

CN119378605APending Publication Date: 2025-01-28ALIBABA CLOUD FEITIAN (HANGZHOU) CLOUD COMPUTING TECH CO LTD

Patent Information

Application Number
CN202411959296.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-27
Publication Date
2025-01-28

AI Technical Summary

Technical Problem

In the prior art, the basic model is first pre-trained with unlabeled data, and then fine-tuned the pre-trained model through supervised instruction data, resulting in poor model performance and low training efficiency.

Method used

By combining the unprepared data and supervised instruction data into a sample data set, the natural language processing model is continued to be trained to obtain the target model. This method ensures the instructions of the model during the pre -training phase, which slows down the disastrous forgetfulness in the fine -tuning stage.

Benefits of technology

It improves the performance and training efficiency of the model, reduces the disaster forgetting phenomenon in the fine -tuning stage, and ensures the accuracy of the model when processing the target text to generate tasks.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119378605A_ABST
    Figure CN119378605A_ABST
Patent Text Reader

Abstract

The invention discloses a model-based task processing method, a model training method and electronic equipment, and relates to the technical field of large models. The method comprises the following steps: determining target prompt information of a target text generation task; the target prompt information is input into a target model for processing, a target text generation result of the target text generation task is obtained, the target model is obtained by pre-training a natural language processing model based on a first sample data set and a second sample data set, the first sample data set is determined by unlabeled data, and the second sample data set is determined by unlabeled data; the second sample data set is determined by supervised instruction data, the unlabeled data is text data which does not contain labeled information, and the supervised instruction data comprises prompt information and a text generation result. According to the method, the technical problem that the performance of the obtained model is poor due to the fact that the basic model is pre-trained through the unlabeled data and then the pre-trained model is finely adjusted through the supervised instruction data in the related technology is solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of large models, and in particular to a method for processing model-based tasks, a model training method, and an electronic device. Background Art

[0002] Pre-training of large language models can learn the basic structure of language and extensive knowledge from a large number of unsupervised samples, greatly improving the performance and generalization ability of the model.

[0003] Pre-training a large language model from scratch requires strong computing power and is a very expensive process. Therefore, related technologies continue to pre-train on a stronger basic model to obtain the required large language model. In this process, first prepare large-scale unlabeled data related to the target domain or task, continue to pre-train the basic model with large-scale unlabeled data, and then perform supervised fine-tuning on the pre-trained model to improve the model's ability to follow instructions.

[0004] It should be noted that the basic model is first pre-trained with unlabeled data, and then the pre-trained model is fine-tuned with supervised instruction data. During the fine-tuning stage, the model is prone to catastrophic forgetting of the knowledge learned in the pre-training stage, resulting in poor model performance. In addition, the number of unlabeled data and supervised instruction data is large, resulting in low model training efficiency.

[0005] To address the above-mentioned problems, no effective solution has been proposed yet. Summary of the invention

[0006] The embodiments of the present application provide a model-based task processing method, a model training method, and an electronic device, so as to at least solve the technical problem in the related art that a basic model is first pre-trained with unlabeled data, and then the pre-trained model is fine-tuned with supervised instruction data, resulting in poor performance of the obtained model.

[0007] According to one aspect of an embodiment of the present application, a model-based task processing method is provided, comprising: determining target prompt information of a target text generation task, wherein the target prompt information is used to describe information required to complete the target text generation task; inputting the target prompt information into a target model for processing to obtain a target text generation result of the target text generation task, wherein the target model is obtained by pre-training a natural language processing model based on a first sample data set and a second sample data set, the first sample data set is determined by unlabeled data, and the second sample data set is determined by supervised instruction data, the unlabeled data is text data that does not contain annotation information, and the supervised instruction data includes prompt information and text generation results.

[0008] Optionally, the target model is obtained in the following manner: obtaining unlabeled data, dividing the unlabeled data into preset batches of first sample data, wherein the preset batches of first sample data constitute a first sample data set, and the unlabeled data are: unlabeled data related to the same type of task as the target text generation task, or unlabeled data in the field to which the target text generation task belongs; obtaining supervised instruction data, dividing the supervised instruction data into preset batches of second sample data, wherein the preset batches of second sample data constitute a second sample data set, and the supervised instruction data are: supervised instruction data related to the same type of task as the target text generation task, or supervised instruction data in the field to which the target text generation task belongs; combining the first sample data and the second sample data of the same batch respectively to obtain preset batches of sample data, wherein a batch of sample data includes a batch of first sample data and a batch of second sample data; continuing to pre-train the natural language processing model according to the preset batches of sample data to obtain the target model.

[0009] Optionally, dividing the supervised instruction data into preset batches of second sample data includes: dividing the unlabeled data into preset batches of unlabeled data; performing word segmentation on any batch of unlabeled data, splicing the word segmentation results, segmenting the splicing results according to a preset text size to obtain data segments corresponding to any batch, and determining the data segments corresponding to any batch as the second sample data of any batch.

[0010] Optionally, dividing the supervised instruction data into preset batches of second sample data includes: when the proportion of the number of supervised instruction data in the overall sample number is less than a preset proportion, sorting the supervised instruction data in order of size to obtain a sorting result, wherein the overall sample number refers to the sum of the number of unlabeled data and supervised instruction data, and the sorting result is the sorted supervised instruction data; dividing the sorting result into preset batches of supervised instruction data, and determining the preset batches of supervised instruction data as the second sample data of the preset batch.

[0011] Optionally, dividing the supervised instruction data into preset batches of second sample data includes: when the proportion of the number of supervised instruction data in the overall sample number is greater than or equal to the preset proportion, dividing the supervised instruction data into different data combinations to obtain a data combination set, wherein the overall sample number refers to the sum of the number of unlabeled data and supervised instruction data, and the size of the data combination is less than or equal to the preset text size; splicing the data in the data combinations in the data combination set to obtain a splicing result set, dividing the splicing result set into preset batches of splicing results, and determining the preset batch of second sample data based on the splicing results of the preset batch, wherein one splicing combination in the splicing result set corresponds to one data combination.

[0012] Optionally, the natural language processing model is continued to be pre-trained according to a preset batch of sample data to obtain a target model, including: iteratively training the natural language processing model according to the preset batch of sample data, and calculating the loss value of the trained model until the loss value of the trained model is less than a preset loss value, or until a preset number of iterations is reached, and the trained model is determined as the target model, wherein, in the process of training the natural language processing model, the first sample data in the sample data in the same batch is input into the natural language processing model before the second sample data, and the loss value of the trained model includes a first loss value and a second loss value, the first loss value is determined by the difference between the predicted value and the actual value of the first sample data and a first loss weight, the second loss value is determined by the difference between the predicted value and the actual value of the second sample data and a second loss weight, and the second loss weight is greater than the first loss weight.

[0013] Optionally, calculating the loss value of the trained model includes: obtaining the output result of the self-attention sublayer of the trained model, wherein the self-attention sublayer blocks the sample data of the same batch according to a preset text size, and calculates the causal mask matrix for the block results to obtain the output result of the self-attention sublayer; obtaining the output result of the feedforward network sublayer of the trained model; calculating the predicted value of the sample data based on the output result of the self-attention sublayer and the output result of the feedforward network sublayer, and calculating the loss value based on the predicted value of the sample data and the actual value of the sample data.

[0014] According to another aspect of an embodiment of the present application, a model training method is also provided, including: obtaining unlabeled data, dividing the unlabeled data into preset batches of first sample data, wherein the unlabeled data is: unlabeled data related to a text generation task of a target type, or unlabeled data under a target domain; obtaining supervised instruction data, dividing the supervised instruction data into preset batches of second sample data, wherein the supervised instruction data is: supervised instruction data related to a text generation task of a target type, or supervised instruction data under a target domain; combining the first sample data and the second sample data of the same batch respectively to obtain preset batches of sample data, wherein a batch of sample data includes a batch of first sample data and a batch of second sample data; continuing to pre-train the natural language processing model according to the preset batch of sample data to obtain a target model.

[0015] According to another aspect of an embodiment of the present application, a model-based task processing method is also provided, including: a cloud server receives target prompt information of a target text generation task sent by a client, wherein the target prompt information is used to describe information required to complete the target text generation task; the cloud server processes the target prompt information through a target model to obtain a target text generation result of the target text generation task, wherein the target model is obtained by pre-training a natural language processing model based on a first sample data set and a second sample data set, the first sample data set is determined by unlabeled data, and the second sample data set is determined by supervised instruction data, the unlabeled data is text data that does not contain annotation information, and the supervised instruction data includes prompt information and text generation results; the cloud server sends the text generation result to the client.

[0016] According to another aspect of the embodiments of the present application, an electronic device is also provided, including: a memory storing an executable program; a processor connected to the memory via a bus and used to run the program, wherein the method of each embodiment of the present application is executed when the program is running.

[0017] According to another aspect of an embodiment of the present application, a computer-readable storage medium is also provided, the computer-readable storage medium including a stored executable program, wherein when the executable program is running, the device where the computer-readable storage medium is located is controlled to execute the methods in each embodiment of the present application.

[0018] According to another aspect of an embodiment of the present application, a computer program product is also provided, including a non-volatile computer-readable storage medium, wherein the non-volatile computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method in each embodiment of the present application is implemented.

[0019] In an embodiment of the present application, target prompt information of a target text generation task is input into a target model for processing to obtain a target text generation result of the target text generation task. Since the target model is obtained by pre-training a natural language processing model based on a first sample data set and a second sample data set, the first sample data set is determined by unlabeled data, and the second sample data set is determined by supervised instruction data, thereby achieving the target model by pre-training the natural language processing model with unlabeled data and supervised instruction data, ensuring the instruction-following ability of the target model in the pre-training stage, and slowing down catastrophic forgetting caused by the fine-tuning stage, thereby solving the technical problem in the related art of first pre-training the basic model with unlabeled data and then fine-tuning the pre-trained model with supervised instruction data, resulting in poor performance of the obtained model.

[0020] It is easy to notice that the above general description and the following detailed description are only for the purpose of exemplifying and explaining the present application, and do not constitute a limitation of the present application. BRIEF DESCRIPTION OF THE DRAWINGS

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

[0022] Figure 1 is a schematic diagram of a model deployment method according to an embodiment of the present application;

[0023] Figure 2 is a flowchart of a method for processing a model-based task according to an embodiment of the present application;

[0024] Figure 3 is a schematic diagram of calculating an attention matrix according to an embodiment of the present application;

[0025] Figure 4 is a flowchart of another method for processing a model-based task according to an embodiment of the present application;

[0026] Figure 5 is a flow chart of a model training method according to an embodiment of the present application;

[0027] Figure 6 is a flowchart of another model training method according to an embodiment of the present application;

[0028] Figure 7 is a schematic diagram of a processing device for a model-based task according to an embodiment of the present application;

[0029] Figure 8 is a schematic diagram of a training device for a model according to an embodiment of the present application;

[0030] Fig. 9 is a structural block diagram of a computing device according to an embodiment of the present application;

[0031] Fig.10 It is a structural block diagram of an electronic device according to an embodiment of the present application. DETAILED DESCRIPTION

[0032] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present application.

[0033] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0034] The technical solution provided in this application is mainly implemented using large-scale model technology. The large model here refers to a deep learning model with large-scale model parameters, which can usually contain hundreds of millions, tens of billions, hundreds of billions, trillions or even more than 10 trillion model parameters. The large model can also be called a foundation model / foundation model. The large model is pre-trained with large-scale unlabeled corpus to produce a pre-trained model with more than 100 million parameters. This model can adapt to a wide range of downstream tasks, and the model has good generalization ability, such as large-scale language model (LLM), multi-modal pre-training model, etc.

[0035] It should be noted that when the large model is actually applied, the pre-trained model can be fine-tuned through a small number of samples, so that the large model can be applied to different tasks. For example, the large model can be widely used in natural language processing (NLP), computer vision, speech processing and other fields, specifically in computer vision tasks such as visual question answering (VQA), image caption (IC), image generation, etc. It can also be widely used in natural language processing tasks such as text-based sentiment classification, text summary generation, machine translation, etc. Therefore, the main application scenarios of the large model include but are not limited to digital assistants, intelligent robots, search, online education, office software, e-commerce, intelligent design, etc.

[0036] According to an embodiment of the present application, a model-based task processing method is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.

[0037] Considering the huge number of model parameters of large models and the limited computing resources of mobile terminals, Figure 1 is a schematic diagram of a model deployment method according to an embodiment of the present application. The above method provided in the embodiment of the present application can be applied to Figure 1 The application scenarios shown are not limited to these. Figure 1 In the application scenario shown, the large model is deployed in the server 10, and the server 10 can be connected to one or more client devices 20 through a local area network connection, a wide area network connection, an Internet connection, or other types of data networks. The client device 20 here may include but is not limited to: a smart phone, a tablet computer, a laptop computer, a PDA, a personal computer, a smart home device, a vehicle-mounted device, etc. The client device 20 can interact with the user through a graphical user interface to implement the call of the large model, thereby implementing the method provided in the embodiment of the present application.

[0038] In an embodiment of the present application, a system composed of a client device and a server can execute the following steps: the client device executes: determining target prompt information for a target text generation task, wherein the target prompt information is used to describe information required to complete the target text generation task; the server executes: inputting the target prompt information into a target model for processing to obtain a target text generation result for the target text generation task, wherein the target model is obtained by pre-training a natural language processing model based on a first sample data set and a second sample data set, the first sample data set is determined by unlabeled data, and the second sample data set is determined by supervised instruction data, the unlabeled data is text data that does not contain annotation information, and the supervised instruction data includes prompt information and text generation results.

[0039] It should be noted that, with the rapid development of high-performance computing units, in other application scenarios, the above method provided in the embodiment of the present application can also be applied to the model all-in-one machine. In an optional embodiment, a plurality of models are built into the model all-in-one machine, and the user can choose to adjust a model as needed to obtain the user's own model, so that the high-performance computing unit built into the model all-in-one machine can directly call the adjusted model to execute the above method provided in the embodiment of the present application. In another optional embodiment, a trained model is built into the large model all-in-one machine, so that the high-performance computing unit built into the model all-in-one machine can directly call the model to execute the above method provided in the embodiment of the present application.

[0040] Furthermore, when users need to train their own models, they can also upload their own data sets through the client, which are sent by the client to the server, so that the server can adjust the pre-trained model with the data set to obtain the user's own model and then deploy it to the production environment. In order to facilitate users' needs for model adjustment, the server can provide complete adjustment tools, development frameworks and processes, and can support multiple adjustment strategies, so that the adjusted model can better adapt to applications in different fields and achieve a high degree of customization.

[0041] Under the above operating environment, this application provides Figure 2 The model-based approach to the task is shown. Figure 2 FIG. 1 is a flowchart of a method for processing a model-based task according to an embodiment of the present application. Figure 2 As shown, the method may include the following steps:

[0042] Step S202, determining target prompt information of the target text generation task, wherein the target prompt information is used to describe information required to complete the target text generation task.

[0043] Exemplarily, the target text generation task may be a text generation task of a target type, for example, a language template generation task, a machine translation task, a dialogue generation task, a summary generation task, a code generation task, and the like.

[0044] Exemplarily, the target text generation task may also be a text generation task in a target field, for example, a text generation task in the financial field, a text generation task in the legal field, a text generation task in the business field, etc.

[0045] The target prompt information is a kind of input information input into the target model, which is used to describe the background of the target text generation task. In an optional embodiment, the target text generation task can be a code generation task, and the target prompt information describes the implementation function of the code and the implementation language of the code.

[0046] Step S204, input the target prompt information into the target model for processing to obtain the target text generation result of the target text generation task, wherein the target model is obtained by pre-training the natural language processing model based on the first sample data set and the second sample data set, the first sample data set is determined by unlabeled data, and the second sample data set is determined by supervised instruction data, the unlabeled data is text data that does not contain annotation information, and the supervised instruction data includes prompt information and text generation results.

[0047] Among them, unlabeled data refers to text data without manual annotation information, which can come from various channels such as the Internet, books, articles, etc. Unlabeled data can be unlabeled data related to the same type of tasks as the target text generation task, which is used to allow the natural language processing model to learn the language structure, grammar, vocabulary usage and potential semantic information of the same type of text generation tasks during the pre-training stage. Unlabeled data can also be unlabeled data in the field to which the target text generation task belongs, which is used to allow the natural language processing model to learn the language structure, grammar, vocabulary usage and potential semantic information of the text generation tasks in the same field during the pre-training stage.

[0048] Among them, the supervised instruction data includes specific task instructions (prompt information for the text generation task) and paired data of the expected output (text generation results associated with the text generation task). When the unlabeled data is unlabeled data related to the same type of task as the target text generation task, the supervised instruction data is supervised instruction data related to the same type of task. When the unlabeled data can also be unlabeled data in the field to which the target text generation task belongs, the supervised instruction data is supervised instruction data in the same field.

[0049] It should be noted that in the related art, supervised instruction data is used in the fine-tuning stage of the model, that is, in the pre-training stage of the model, the natural language processing model is further pre-trained through unlabeled data, and the obtained pre-trained model already has basic language understanding capabilities. In the fine-tuning stage of the model, the pre-trained model is allowed to learn supervised instruction data so that the model can better perform the target type of text generation tasks or text generation tasks in the target field. However, catastrophic forgetting is prone to occur in the fine-tuning stage of the model, that is, the model may forget the knowledge learned in the pre-training stage and only focus on specific tasks in the supervised instruction data.

[0050] Therefore, in this embodiment, in the pre-training stage, the natural language processing model is no longer pre-trained only with unlabeled data. Instead, the natural language processing model is pre-trained with a first sample data set obtained by processing the unlabeled data and a second sample data set obtained by processing the supervised instruction data to obtain a target model. The instruction-following ability of the target model is guaranteed in the pre-training stage. The instruction-following ability of the target model is no longer improved by relying solely on the fine-tuning stage. The catastrophic forgetting caused by the supervised fine-tuning stage is also mitigated, thereby improving the performance of the target model and improving the accuracy of the text generation results obtained by the target model when processing the target text generation task.

[0051] In an embodiment of the present application, target prompt information of a target text generation task is input into a target model for processing to obtain a target text generation result of the target text generation task. Since the target model is obtained by pre-training a natural language processing model based on a first sample data set and a second sample data set, the first sample data set is determined by unlabeled data, and the second sample data set is determined by supervised instruction data, thereby achieving the target model by pre-training the natural language processing model with unlabeled data and supervised instruction data, ensuring the instruction-following ability of the target model in the pre-training stage, and slowing down catastrophic forgetting caused by the fine-tuning stage, thereby solving the technical problem in the related art of first pre-training the basic model with unlabeled data and then fine-tuning the pre-trained model with supervised instruction data, resulting in poor performance of the obtained model.

[0052] The target model is obtained by pre-training. Optionally, in the model-based task processing method of an embodiment of the present invention, the target model is obtained by: obtaining unlabeled data, dividing the unlabeled data into preset batches of first sample data, wherein the preset batches of first sample data constitute a first sample data set, and the unlabeled data are: unlabeled data related to the same type of tasks as the target text generation task, or unlabeled data in the field to which the target text generation task belongs; obtaining supervised instruction data, dividing the supervised instruction data into preset batches of second sample data, wherein the preset batches of second sample data constitute a second sample data set, and the supervised instruction data are: supervised instruction data related to the same type of tasks as the target text generation task, or supervised instruction data in the field to which the target text generation task belongs; combining the first sample data and the second sample data of the same batch respectively to obtain preset batches of sample data, wherein a batch of sample data includes a batch of first sample data and a batch of second sample data; continuing to pre-train the natural language processing model according to the preset batches of sample data to obtain the target model.

[0053] It should be noted that the unlabeled data and the supervised instruction data have the same relevance to the target text generation task. That is, when the unlabeled data is unlabeled data related to the same type of task as the target text generation task, the supervised instruction data is also supervised instruction data related to the same type of task. When the unlabeled data can also be unlabeled data in the field to which the target text generation task belongs, the supervised instruction data is also supervised instruction data in the same field.

[0054] Among them, processing the unlabeled data may include data cleaning, grouping the cleaned unlabeled data according to the batch number, so as to obtain the first sample data of the preset batch, and the first sample data of the preset batch constitutes the first sample data set. Processing the supervised instruction data may also include data cleaning, grouping the cleaned unlabeled data according to the batch number, so as to obtain the second sample data of the preset batch, and the second sample data of the preset batch constitutes the second sample data set. Batch, that is, Batch, is a collection of sample data processed simultaneously in a training step. For example, the batch number can be 10, then the first sample data set includes 10 batches of first sample data, and the second sample data set includes 10 batches of second sample data.

[0055] Unlabeled data and supervised instruction data are text data. Exemplarily, data cleaning can be performed by first deduplicating data and then eliminating text data with confusing semantics and insufficient knowledge expression. The elimination of text data with confusing semantics and insufficient knowledge expression can be achieved through preset rules and algorithm models. The preset rules can be filtering rules based on keywords and features. When the filtering rules are to filter data that does not meet the rules, the data that hits the rules are eliminated, and the retained text data is data that does not contain specific keywords or features. The algorithm model is used to evaluate the quality of text data and output the PPL (Perplexity) value. If the PPL value of the text data is greater than the preset PPL value, it means that there is a high probability that the quality of the text data is low (such as confusing semantics or insufficient knowledge expression). Text data with a large PPL value can be selectively eliminated, and the retained text data is high-quality data.

[0056] Among them, data grouping is to group the high-quality data obtained after cleaning into preset batches of data, specifically, to group the cleaned unlabeled data into preset batches of first sample data to obtain a first sample data set, and to group the cleaned supervised instruction data into preset batches of second sample data to obtain a second sample data set. For example, the preset batch can be 10 batches, and batch numbers can be set in sequence for the 10 batches of first sample data, and batch numbers can be set in sequence for the 10 batches of second sample data. The first sample data and the second sample data of the same batch are respectively combined according to the batch numbers to obtain 10 batches of sample data. The natural language processing model is continued to be pre-trained according to the preset batches of sample data. Specifically, the 10 batches of sample data are sequentially input into the natural language processing model, and the parameters of the model are continuously adjusted until the training end condition is reached.

[0057] This embodiment cleans and groups the unlabeled data and the supervised instruction data respectively to obtain preset batches of high-quality first sample data and second sample data, that is, the first sample data set and the second sample data set. The natural language processing model is further pre-trained through the first sample data set and the second sample data set to obtain the target model. In the pre-training stage, the instruction-following ability of the model is guaranteed, the catastrophic forgetting caused by the supervised fine-tuning stage is mitigated, and the performance of the model is improved.

[0058] The scale of unlabeled data is very large. In order to improve the training efficiency of the target model, optionally, in the model-based task processing method of an embodiment of the present invention, the supervised instruction data is divided into preset batches of second sample data, including: dividing the unlabeled data into preset batches of unlabeled data; performing word segmentation on any batch of unlabeled data, splicing the word segmentation results, segmenting the splicing results according to a preset text size to obtain data segments corresponding to any batch, and determining the data segments corresponding to any batch as the second sample data of any batch.

[0059] For example, the size of the unlabeled data in the same batch is inconsistent. In the process of training the model, there are a lot of invalid calculations caused by padding. The unlabeled data is text data. In order to make full use of computing resources, the unlabeled data in the same batch are first segmented, and then the segmentation results are spliced. The segmentation results can be separated by terminators (for example,<im_end> ) to obtain a splicing result, and then segment it according to the preset text size to obtain data segments, each of which is a first sample data, to ensure that each first sample data is of fixed length. It should be noted that the preset text size is a larger text size (which can be the maximum text size) when the computing power resources allow when training the model. For example, if the GPU video memory is 80G, assuming that the maximum text data it supports processing is 64k, multiple data can be spliced ​​under 64k, thereby greatly reducing the amount of first sample data.

[0060] In this embodiment, the unlabeled data of the same batch are segmented and then concatenated and segmented. The first sample data obtained after segmentation reaches a larger input size (that is, a preset text size) supported by the computing power resources when training the model, ensuring that the calculation process of the first sample data in the first sample data set during the training model is effective, and reducing the number of samples, thereby improving the utilization rate of computing power resources during the training process.

[0061] In order to improve the training efficiency of the target model while ensuring the training effect of the target model, optionally, in the model-based task processing method of an embodiment of the present invention, when the proportion of the number of supervised instruction data in the overall number of samples is less than a preset proportion, the supervised instruction data is sorted in order of size to obtain a sorting result, wherein the overall number of samples refers to the sum of the number of unlabeled data and the number of supervised instruction data, and the sorting result is the sorted supervised instruction data; the sorting result is divided into preset batches of supervised instruction data, and the preset batches of supervised instruction data are determined as the second sample data of the preset batch.

[0062] Exemplarily, for supervised instruction data, the proportion of its data size in the total sample quantity is determined to determine the relative amount of supervised instruction data. For example, the preset proportion is 10%, and the proportion of the number of supervised instruction data in the total sample quantity is less than 10% of the total sample quantity, indicating that the supervised instruction data is relatively small in quantity.

[0063] It should be noted that when the number of supervised instruction data is relatively small, if the supervised instruction data is spliced, the number of samples obtained after splicing will be even smaller, which will lead to poor model optimization results. For example, the total number of samples is 10,000, and the number of supervised instruction data is only more than 1,000. Each supervised instruction data is usually shorter than the unlabeled data (for example, a piece of data is only a few hundred tokens in size). If the supervised instruction data is spliced ​​with a very long sample size (such as 64k), the number of samples obtained after splicing is only dozens. Since the update of model parameters during model training is performed based on each sample as a dimension, the fewer the number of samples, the fewer the number of updates to the model, and the poorer the model optimization effect.

[0064] Therefore, in this embodiment, when the number of supervised instruction data is relatively small, in order to ensure that the data scale of the two sample data, the first sample data and the second sample data, is within a certain ratio and to avoid the supervised instruction data being too sparse after splicing, the supervised instruction data is not spliced, but all the supervised instruction data are sorted and grouped by size, and those with similar sizes are grouped into a batch to obtain grouped data of different batches, and try to ensure that the sample sizes of the second sample data in the same batch are close, thereby improving the computational efficiency when training the model.

[0065] In order to improve the training efficiency of the target model while ensuring the training effect of the target model, optionally, in the model-based task processing method of an embodiment of the present invention, dividing the supervised instruction data into preset batches of second sample data includes: when the proportion of the number of supervised instruction data in the overall sample number is greater than or equal to the preset proportion, dividing the supervised instruction data into different data combinations to obtain a data combination set, wherein the overall sample number refers to the sum of the number of unlabeled data and supervised instruction data, and the size of the data combination is less than or equal to the preset text size; splicing the data in the data combinations in the data combination set to obtain a splicing result set, dividing the splicing result set into preset batches of splicing results, and determining the preset batch of second sample data with the splicing results of the preset batch, wherein one splicing combination in the splicing result set corresponds to one data combination.

[0066] Exemplarily, for the supervised instruction data, the proportion of its data size in the total sample quantity is determined to determine the relative amount of the supervised instruction data. For example, the preset proportion is 10%, and the proportion of the supervised instruction data in the total sample quantity is greater than or equal to 10% of the total sample quantity, indicating that the supervised instruction data is relatively large in quantity.

[0067] When the number of supervised instruction data is relatively large, the supervised instruction data can be spliced ​​to reduce the number of samples and improve the computational efficiency when training the model. It should be noted that since the supervised instruction data is relatively short, the data integrity of a single sample needs to be guaranteed. Therefore, all supervised instruction data need to be reasonably combined and spliced ​​to reduce the number of samples while ensuring that all instruction data will not be lost due to information truncation, and to reduce invalid padding tokens.

[0068] Exemplarily, there are 10 supervised instruction data: 83, 345, 934, 456, 672, 123, 567, 486, 788, 95. The preset text size is 1024, which is the maximum text size allowed by computing resources when training the model. It is necessary to ensure that each data combination is less than or equal to 1024, no data loss will occur, and at the same time, as little space as possible needs to be left. Therefore, first sort the 10 data to get a sequence from 83 to 934, then take the maximum and minimum values ​​from the beginning and end of the sequence respectively, and concatenate them to see if the concatenation result satisfies less than 1024. If it is less than 1024, continue to add data; if it is greater than or equal to 1024, stop adding data. Output this combination to get a grouping result and update the sequence. Next time, take the maximum and minimum values ​​from the beginning and end of the updated sequence respectively and concatenate them until all 10 data are traversed and concatenated into 5 second sample data: [934, 83], [788, 123, 95], [672, 345], [567, 456],

[486] .

[0069] This embodiment groups and splices supervised instruction data so that each grouping and splicing result is as close as possible to the maximum text input size supported by the computing resources when training the model. At the same time, the instruction data can avoid information loss caused by text truncation, which can greatly reduce the number of samples involved in training, and further improve the model training efficiency without affecting the model training effect.

[0070] Optionally, in the model-based task processing method of an embodiment of the present invention, the natural language processing model is continued to be pre-trained according to a preset batch of sample data to obtain a target model, including: iteratively training the natural language processing model according to the preset batch of sample data, and calculating the loss value of the trained model until the loss value of the trained model is less than a preset loss value, or until a preset number of iterations is reached, and the trained model is determined as the target model, wherein, in the process of training the natural language processing model, the first sample data in the sample data in the same batch is input into the natural language processing model before the second sample data, and the loss value of the trained model includes a first loss value and a second loss value, the first loss value is determined by the difference between the predicted value and the actual value of the first sample data and a first loss weight, and the second loss value is determined by the difference between the predicted value and the actual value of the second sample data and a second loss weight, and the second loss weight is greater than the first loss weight.

[0071] When iteratively training the model in the pre-training phase, each round of training will input batches of sample data into the natural language processing model in turn, and the next round of training will be carried out after one round of training is completed. In the process of continuing pre-training, the next most likely token is predicted based on the existing text sequence. After predicting each token, the model will calculate the difference between the predicted token and the actual token to obtain the loss value, and accumulate these loss values ​​to calculate the total loss value of a batch. By updating the model parameters of the model, the total loss value is minimized until the model converges or reaches the preset training rounds.

[0072] It should be noted that in each round of training, a preset batch of sample data is input into the natural language processing model for model training. Considering that the first sample data is unlabeled and the second sample data is supervised, the second sample data has higher quality. Therefore, when inputting each batch of sample data, the sample data is input into the natural language processing model in the order of first inputting the first sample data and then the second sample data for continued pre-training, so that the model can learn easy knowledge first and then learn complex knowledge, and the training effect is better.

[0073] It should also be noted that the loss value of the model includes two parts, the loss value of the first sample data and the loss value corresponding to the second sample data. The first loss value is obtained by weighted summing up the difference between the predicted value and the actual value of the first sample data and the first loss weight, and the second loss value is obtained by weighted summing up the difference between the predicted value and the actual value of the second sample data and the second loss weight. This embodiment sets different loss weights for different types of sample data. Compared with the unlabeled first sample data, the supervised second sample data set sets a larger weight coefficient, so that the calculation of the loss value is more accurate and the model updating effect is better.

[0074] In addition, it should be noted that in the related art, the training of a large language model is divided into two stages. The first stage is pre-training, and the second stage is fine-tuning. During the training process of the second stage, it is easy to forget the knowledge of the pre-training stage, resulting in catastrophic forgetting. This embodiment continues pre-training according to unlabeled data and supervised instruction data in the pre-training stage. The pre-trained model can be used to perform text generation tasks. After the pre-training stage, the fine-tuning stage can be set or not. Both training methods can achieve the effect of reducing catastrophic forgetting. This embodiment does not limit the setting of the fine-tuning stage.

[0075] In order to avoid information interference between samples of different unlabeled data or supervised instruction data during the training model process, optionally, in the model-based task processing method of an embodiment of the present invention, calculating the loss value of the trained model includes: obtaining the output result of the self-attention sublayer of the trained model, wherein the self-attention sublayer blocks the sample data of the same batch according to a preset text size, and calculates the causal mask matrix for the block results to obtain the output result of the self-attention sublayer; obtaining the output result of the feedforward network sublayer of the trained model; calculating the predicted value of the sample data based on the output result of the self-attention sublayer and the output result of the feedforward network sublayer, and calculating the loss value based on the predicted value of the sample data and the actual value of the sample data.

[0076] Specifically, the output results of the self-attention sublayer and the output results of the feedforward network sublayer are mapped into a vector through linear transformation, and then the vector is converted into a probability distribution through the loss function. The probability distribution represents the predicted value of the token in the sample data, and the predicted probability distribution is compared with the actual token, and the loss value is calculated based on the comparison result.

[0077] It should be noted that the natural language processing model calculates the attention matrix in the self-attention sublayer. In the sample data within a batch, considering that attention calculations will be performed between different sample data and there will be interference between sample data, this embodiment divides the data into blocks according to the size of the actual sample data to obtain fixed-length block data (the supervised instruction data that is smaller than the preset text size is padded, and the second sample data obtained after padding is also fixed-length). The mask calculation of the causal attention mechanism is performed inside each sample data to obtain the causal mask matrix. Figure 3 is a schematic diagram of calculating the attention matrix according to an embodiment of the present application, such as Figure 3 As shown in the figure, the model is guaranteed to predict the next token only based on the past and current tokens in the same sample data, and finally multiple causal mask matrices are calculated to obtain the attention matrix.

[0078] In addition, it should be noted that the interference between the pre-trained unlabeled data has little effect on the calculation of attention, while the interference between the supervised instruction data has a greater impact on the calculation of attention. If there are more supervised instruction data, the sample data can be divided into blocks and the attention matrix can be calculated. If there are fewer supervised instruction data, it is not necessary to divide the data into blocks, thereby reducing the complexity of the algorithm while ensuring the training effect of the model.

[0079] This embodiment calculates the block attention matrix of each sample data in blocks to ensure that there is no mutual interference between sample data during training. At the same time, it supports attention calculation of variable sequence size and divides the block attention matrix into multiple causal mask matrices for separate calculation, thereby further avoiding invalid calculations and reducing the use of computing resources when training the model, significantly improving the training and inference speed of the model.

[0080] According to an embodiment of the present application, a method for processing a model-based task is also provided. Figure 4 is a flowchart of another method for processing a model-based task according to an embodiment of the present application, such as Figure 4 As shown, including:

[0081] Step S402: the cloud server receives target prompt information of the target text generation task sent by the client, wherein the target prompt information is used to describe information required to complete the target text generation task.

[0082] Exemplarily, the target text generation task may be a text generation task of a target type, for example, a language template generation task, a machine translation task, a dialogue generation task, a summary generation task, a code generation task, and the like.

[0083] Exemplarily, the target text generation task may also be a text generation task in a target field, for example, a text generation task in the financial field, a text generation task in the legal field, a text generation task in the business field, etc.

[0084] The target prompt information is a kind of input information input into the target model, which is used to describe the background of the target text generation task. In an optional embodiment, the target text generation task can be a code generation task, and the target prompt information describes the implementation function of the code and the implementation language of the code.

[0085] In step S404, the cloud server processes the target prompt information through the target model to obtain a target text generation result of the target text generation task, wherein the target model is obtained by pre-training a natural language processing model based on a first sample data set and a second sample data set, the first sample data set is determined by unlabeled data, and the second sample data set is determined by supervised instruction data, the unlabeled data is text data that does not contain annotation information, and the supervised instruction data includes prompt information and text generation results.

[0086] Among them, unlabeled data refers to text data without manual annotation information, which can come from various channels such as the Internet, books, articles, etc. Unlabeled data can be unlabeled data related to the same type of tasks as the target text generation task, which is used to allow the natural language processing model to learn the language structure, grammar, vocabulary usage and potential semantic information of the same type of text generation tasks during the pre-training stage. Unlabeled data can also be unlabeled data in the field to which the target text generation task belongs, which is used to allow the natural language processing model to learn the language structure, grammar, vocabulary usage and potential semantic information of the text generation tasks in the same field during the pre-training stage.

[0087] Among them, the supervised instruction data includes specific task instructions (prompt information for the text generation task) and paired data of the expected output (text generation results associated with the text generation task). When the unlabeled data is unlabeled data related to the same type of task as the target text generation task, the supervised instruction data is supervised instruction data related to the same type of task. When the unlabeled data can also be unlabeled data in the field to which the target text generation task belongs, the supervised instruction data is supervised instruction data in the same field.

[0088] It should be noted that in the related art, supervised instruction data is used in the fine-tuning stage of the model, that is, in the pre-training stage of the model, the natural language processing model is further pre-trained through unlabeled data, and the obtained pre-trained model already has basic language understanding capabilities. In the fine-tuning stage of the model, the pre-trained model is allowed to learn supervised instruction data so that the model can better perform the target type of text generation tasks or text generation tasks in the target field. However, catastrophic forgetting is prone to occur in the fine-tuning stage of the model, that is, the model may forget the knowledge learned in the pre-training stage and only focus on specific tasks in the supervised instruction data.

[0089] Therefore, in this embodiment, in the pre-training stage, the natural language processing model is no longer pre-trained only with unlabeled data. Instead, the natural language processing model is pre-trained with a first sample data set obtained by processing the unlabeled data and a second sample data set obtained by processing the supervised instruction data to obtain a target model. The instruction-following ability of the target model is guaranteed in the pre-training stage. The instruction-following ability of the target model is no longer improved by relying solely on the fine-tuning stage. The catastrophic forgetting caused by the supervised fine-tuning stage is also mitigated, thereby improving the performance of the target model and improving the accuracy of the text generation results obtained by the target model when processing the target text generation task.

[0090] Step S406: The cloud server sends the text generation result to the client.

[0091] In an embodiment of the present application, a cloud server receives target prompt information of a target text generation task sent by a client, wherein the target prompt information is used to describe the information required to complete the target text generation task; the cloud server processes the target prompt information through a target model to obtain a target text generation result of the target text generation task, wherein the target model is obtained by pre-training a natural language processing model based on a first sample data set and a second sample data set, wherein the first sample data set is determined by unlabeled data, and the second sample data set is determined by supervised instruction data, wherein the unlabeled data is text data that does not contain annotation information, and the supervised instruction data includes prompt information and text generation results; the cloud server sends the text generation result to the client. The target model is obtained by pre-training a natural language processing model through unlabeled data and supervised instruction data, and the instruction-following ability of the target model is guaranteed in the pre-training stage, and the catastrophic forgetting caused by the fine-tuning stage is slowed down, thereby solving the technical problem of poor performance of the model obtained by first pre-training the basic model through unlabeled data and then fine-tuning the pre-trained model through supervised instruction data in the related art.

[0092] According to an embodiment of the present application, a model training method is also provided. Figure 5 is a flow chart of a model training method according to an embodiment of the present application, such as Figure 5 As shown, including:

[0093] Step S502, obtaining unlabeled data, and dividing the unlabeled data into preset batches of first sample data, wherein the unlabeled data is: unlabeled data related to a target type of text generation task, or unlabeled data in a target domain.

[0094] Exemplarily, target-type text generation tasks may be language template generation tasks, machine translation tasks, dialogue generation tasks, summary generation tasks, and code generation tasks, etc. Target-domain text generation tasks may be text generation tasks in the financial domain, text generation tasks in the legal domain, and text generation tasks in the business domain, etc.

[0095] Among them, unlabeled data refers to text data without manual annotation information, which can come from various channels such as the Internet, books, and articles. Unlabeled data related to the target type of text generation task is used to allow the natural language processing model to learn the language structure, grammar, vocabulary usage, and potential semantic information of the same type of text generation task during the pre-training stage. Unlabeled data in the target domain is used to allow the natural language processing model to learn the language structure, grammar, vocabulary usage, and potential semantic information of the same domain of text generation tasks during the pre-training stage.

[0096] The processing of the unlabeled data may include data cleaning, and grouping the cleaned unlabeled data according to the batch number, so as to obtain first sample data of a preset batch, and the first sample data of the preset batch constitutes a first sample data set.

[0097] Step S504, obtaining supervised instruction data, and dividing the supervised instruction data into preset batches of second sample data, wherein the supervised instruction data is: supervised instruction data related to the target type of text generation task, or supervised instruction data under the target domain.

[0098] Among them, the supervised instruction data includes specific task instructions (prompt information associated with the text generation task) and paired data of the expected output (text generation results associated with the text generation task). It should be noted that the unlabeled data and the supervised instruction data have the same relevance to the text generation task. In the case where the unlabeled data is unlabeled data related to the target type of text generation task, the supervised instruction data is supervised instruction data related to the same type of task. In the case where the unlabeled data is unlabeled data related to the text generation task in the target domain, the supervised instruction data is supervised instruction data in the same domain.

[0099] Among them, processing the supervised instruction data may also include data cleaning, grouping the cleaned unlabeled data according to the batch number, so as to obtain second sample data of a preset batch, and the second sample data of the preset batch constitutes a second sample data set.

[0100] Step S506 , combining the first sample data and the second sample data of the same batch respectively to obtain a preset batch of sample data, wherein one batch of sample data includes one batch of first sample data and one batch of second sample data.

[0101] Exemplarily, the preset batches can be 10 batches, batch numbers can be set in sequence for the first sample data of the 10 batches, batch numbers can be set in sequence for the second sample data of the 10 batches, and the first sample data and the second sample data of the same batch are respectively combined according to the batch numbers to obtain 10 batches of sample data.

[0102] Step S508, continue pre-training the natural language processing model according to the preset batch of sample data to obtain a target model.

[0103] Exemplarily, the preset batches may be 10 batches, and the sample data of the 10 batches are input into the natural language processing model in sequence, and the parameters of the model are continuously adjusted until the training end condition is reached.

[0104] It should be noted that in the related art, supervised instruction data is used in the fine-tuning stage of the model, that is, in the pre-training stage of the model, the natural language processing model is further pre-trained through unlabeled data, and the obtained pre-trained model already has basic language understanding capabilities. In the fine-tuning stage of the model, the pre-trained model is allowed to learn supervised instruction data so that the model can better perform the target type of text generation tasks or text generation tasks in the target field. However, catastrophic forgetting is prone to occur in the fine-tuning stage of the model, that is, the model may forget the knowledge learned in the pre-training stage and only focus on specific tasks in the supervised instruction data.

[0105] Therefore, in this embodiment, in the pre-training stage, the natural language processing model is no longer pre-trained only with unlabeled data. Instead, the natural language processing model is pre-trained with a first sample data set obtained by processing the unlabeled data and a second sample data set obtained by processing the supervised instruction data to obtain a target model. The instruction-following ability of the target model is guaranteed in the pre-training stage. The instruction-following ability of the target model is no longer improved by relying solely on the fine-tuning stage. The catastrophic forgetting caused by the supervised fine-tuning stage is also mitigated, thereby improving the performance of the target model and improving the accuracy of the text generation results obtained by the target model when processing the target text generation task.

[0106] In an embodiment of the present application, unlabeled data is obtained, and the unlabeled data is processed to obtain a first sample data set, wherein the unlabeled data is: unlabeled data related to the target type of text generation task, or unlabeled data in the target field; supervised instruction data is obtained, and the supervised instruction data is processed to obtain a second sample data set, wherein the supervised instruction data is: supervised instruction data related to the target type of text generation task, or supervised instruction data in the target field; the natural language processing model is continued to be pre-trained according to the first sample data set and the second sample data set to obtain a target model. The target model is obtained by pre-training the natural language processing model with unlabeled data and supervised instruction data, and the instruction-following ability of the target model is guaranteed in the pre-training stage, and the catastrophic forgetting caused by the fine-tuning stage is slowed down, thereby solving the technical problem of poor performance of the model obtained by first pre-training the basic model with unlabeled data and then fine-tuning the pre-trained model with supervised instruction data in the related technology.

[0107] According to an embodiment of the present application, a model training method is also provided. Figure 6 is a flowchart of another model training method according to an embodiment of the present application, such as Figure 6 As shown, including:

[0108] First, perform preliminary screening and quality filtering of the data to filter out low-quality text data such as semantic confusion, insufficient knowledge expression, and repeated entries from the data (including pre-trained unlabeled data and supervised instruction data).

[0109] Then, for the pre-trained unlabeled data, the texts in the same batch are segmented and concatenated, and the samples are separated by terminators (e.g.<im_end> ) are connected, and then segmented according to the preset text size (a larger text size is preset if the computing resources support it) to ensure that each sample is of fixed length. For supervised instruction data, first determine the proportion of the data size to the total number to determine the relative number of supervised instruction data. When the relative number is small, for example, less than 10% of the total number of samples, all supervised instruction data are sorted and grouped by size to obtain samples of different batches, and try to ensure that the sample sizes within the batch are close, thereby improving computing efficiency. When the relative number is large, since the supervised instruction data is relatively short, it is necessary to ensure the data integrity of its single sample, and reasonably combine and splice all the data to ensure that the data combination is close to the preset text size and that all instruction data will not be affected by information loss caused by data truncation.

[0110] Furthermore, after all the sample data are concatenated or grouped, they are sent to the natural language processing model for training in the order of unlabeled data first and supervised instruction data. The training method uses the Token prediction task in the autoregressive model. When calculating the loss function, different loss weight coefficients are used for different types of data samples, and a larger loss weight coefficient is used for supervised data. In order to avoid information interference between samples of different unlabeled data and supervised instruction data, the sample data of the same batch is divided into blocks through the block diagonal attention mechanism, and the causal mask matrix of each sample is calculated, thereby further avoiding invalid calculations and improving calculation efficiency.

[0111] This embodiment performs preliminary screening and quality filtering on the pre-trained unlabeled data and supervised instruction data, and then performs data grouping and splicing processing on the two types of data according to different processing logics, so that the processed sample data is close to the maximum input size supported by the model, ensuring that the computing power utilization is maximized as much as possible, and then continuing to pre-train the model with unlabeled data and supervised instruction data under the sample attention mechanism. Ensure that there is no mutual interference between samples during the training process, and efficiently implement the continued pre-training of models in vertical fields or related tasks, so that the model can learn domain knowledge while ensuring its ability to follow instructions. On the basis of ensuring the model effect, the computing power utilization can be improved by 10%-30% compared with related technologies.

[0112] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with the relevant laws, regulations and standards of relevant countries and regions, and provide corresponding operation entrances for users to choose to authorize or refuse.

[0113] It should be noted that, for the aforementioned method embodiments, for the sake of simplicity, they are all expressed as a series of action combinations, but those skilled in the art should be aware that the present application is not limited by the described order of actions, because according to the present application, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by the present application.

[0114] Through the description of the above implementation methods, those skilled in the art can clearly understand that the method according to the above embodiment can be implemented by means of software plus a necessary general hardware platform, and of course, it can also be implemented by hardware. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, disk, CD), and includes a number of instructions for a terminal device (which can be a mobile phone, computer, server, or network device, etc.) to execute the methods described in each embodiment of the present application.

[0115] According to an embodiment of the present application, a device for implementing the above-mentioned model-based task processing method is also provided. Figure 7 is a schematic diagram of a processing device for a model-based task according to an embodiment of the present application, such as Figure 7 As shown, the device includes: a determination unit 702 and a processing unit 704.

[0116] A determination unit 702 is used to determine target prompt information of a target text generation task, wherein the target prompt information is used to describe information required to complete the target text generation task;

[0117] The processing unit 704 is used to input the target prompt information into the target model for processing to obtain the target text generation result of the target text generation task, wherein the target model is obtained by pre-training the natural language processing model based on the first sample data set and the second sample data set, the first sample data set is determined by unlabeled data, and the second sample data set is determined by supervised instruction data. The unlabeled data is text data that does not contain annotation information, and the supervised instruction data includes prompt information and text generation results.

[0118] Optionally, in the model-based task processing device of the embodiment of the present invention, the device also includes a model training unit for training the target model, and the model training unit includes: a first acquisition module for acquiring unlabeled data and dividing the unlabeled data into preset batches of first sample data, wherein the preset batches of first sample data constitute a first sample data set, and the unlabeled data are: unlabeled data related to the same type of tasks as the target text generation task, or unlabeled data in the field to which the target text generation task belongs; a second acquisition module for acquiring supervised instruction data and dividing the supervised instruction data into preset batches of second sample data, wherein the preset batches of second sample data constitute a second sample data set, and the supervised instruction data are: supervised instruction data related to the same type of tasks as the target text generation task, or supervised instruction data in the field to which the target text generation task belongs; a combination module for combining the first sample data and the second sample data of the same batch respectively to obtain preset batches of sample data, wherein a batch of sample data includes a batch of first sample data and a batch of second sample data; a training module for continuing to pre-train the natural language processing model according to the preset batches of sample data to obtain a target model.

[0119] Optionally, the first acquisition module includes: a first division submodule, used to divide the unlabeled data into preset batches of unlabeled data; a first determination submodule, used to perform word segmentation on any batch of unlabeled data, splice the word segmentation results, segment the splicing results according to a preset text size, obtain data segments corresponding to any batch, and determine the data segments corresponding to any batch as the second sample data of any batch.

[0120] Optionally, the second acquisition module includes: a sorting submodule, used to sort the supervised instruction data in order of size when the proportion of the number of supervised instruction data in the total number of samples is less than a preset proportion, to obtain a sorting result, wherein the total number of samples refers to the sum of the number of unlabeled data and supervised instruction data, and the sorting result is the sorted supervised instruction data; a second determination submodule, used to divide the sorting results into preset batches of supervised instruction data, and determine the preset batches of supervised instruction data as the second sample data of the preset batch.

[0121] Optionally, the second acquisition module includes: a third division sub-module, used to divide the supervised instruction data into different data combinations to obtain a data combination set when the proportion of the number of supervised instruction data in the overall sample number is greater than or equal to a preset proportion, wherein the overall sample number refers to the sum of the number of unlabeled data and supervised instruction data, and the size of the data combination is less than or equal to a preset text size; a third determination sub-module, used to splice the data in the data combinations in the data combination set to obtain a splicing result set, divide the splicing result set into preset batches of splicing results, and determine the second sample data of the preset batch using the splicing results of the preset batch, wherein one splicing combination in the splicing result set corresponds to one data combination.

[0122] Optionally, the training module is used to iteratively train the natural language processing model according to a preset batch of sample data, and calculate the loss value of the trained model until the loss value of the trained model is less than a preset loss value, or until a preset number of iterations is reached, and the trained model is determined as the target model, wherein, in the process of training the natural language processing model, the first sample data in the sample data in the same batch is input into the natural language processing model before the second sample data, and the loss value of the trained model includes a first loss value and a second loss value, the first loss value is determined by the difference between the predicted value and the actual value of the first sample data and a first loss weight, the second loss value is determined by the difference between the predicted value and the actual value of the second sample data and a second loss weight, and the second loss weight is greater than the first loss weight.

[0123] Optionally, the training module also includes a calculation module for calculating the loss value of the trained model, and the calculation submodule includes: a first acquisition submodule for obtaining the output result of the self-attention sublayer of the trained model, wherein the self-attention sublayer blocks the sample data of the same batch according to a preset text size, and calculates the causal mask matrix for the block results to obtain the output result of the self-attention sublayer; a second acquisition submodule for obtaining the output result of the feedforward network sublayer of the trained model; a calculation submodule for calculating the predicted value of the sample data based on the output result of the self-attention sublayer and the output result of the feedforward network sublayer, and calculating the loss value based on the predicted value of the sample data and the actual value of the sample data.

[0124] According to an embodiment of the present application, another device for implementing the training method of the above model is also provided. Figure 8 is a schematic diagram of a training device for a model according to an embodiment of the present application, such as Figure 8 As shown, the device includes: a first acquisition unit 802 , a second acquisition unit 804 and a training unit 808 .

[0125] A first acquisition unit 802 is used to acquire unlabeled data and divide the unlabeled data into first sample data of a preset batch, wherein the unlabeled data is: unlabeled data related to a target type of text generation task, or unlabeled data in a target field;

[0126] The second acquisition unit 804 is used to acquire supervised instruction data, and divide the supervised instruction data into preset batches of second sample data, wherein the supervised instruction data is: supervised instruction data related to the target type of text generation task, or supervised instruction data in the target field;

[0127] A combining unit 806, configured to combine the first sample data and the second sample data of the same batch respectively to obtain a preset batch of sample data, wherein one batch of sample data includes one batch of first sample data and one batch of second sample data;

[0128] The training unit 808 is used to continue pre-training the natural language processing model according to the first sample data set and the second sample data set to obtain a target model.

[0129] It should be noted that the above-mentioned units and modules correspond to the steps in the above-mentioned embodiments, and are the same as the examples and application scenarios implemented by the corresponding steps, but are not limited to the contents disclosed in the above-mentioned embodiments. It should be noted that the above-mentioned modules or units can be hardware components or software components stored in a memory and processed by one or more processors, and the above-mentioned modules can also be run in the server 10 provided in the above-mentioned embodiments as part of the device.

[0130] It should be noted that the preferred implementation scheme involved in the above embodiments of the present application is the same as the scheme provided in the above embodiments, as well as the application scenario and implementation process, but is not limited to the scheme provided in the above embodiments.

[0131] An embodiment of the present application may provide a computing device. Fig. 9 is a structural block diagram of a computing device according to an embodiment of the present application. Fig. 9 As shown, the computing device 100 may include: one or more ( Fig. 9 (only one is shown) processor 102, memory 104, storage controller, and peripheral interfaces.

[0132] The above-mentioned computing device can be understood as an integrated intelligent terminal, including but not limited to a server, a desktop computer, a PC (Personal Computer), a model all-in-one machine, etc., and the computing device can be pre-installed with the model described in the above-mentioned embodiments of the present application.

[0133] Specifically, the computing device can pre-set multiple types of models, including but not limited to models in the fields of natural language processing, visual processing, speech processing, code processing, multimodal task processing, etc., so as to provide a variety of model choices. In different product forms, the computing device can support one or more model usage methods, including but not limited to model training, model calling, model fine-tuning, model deployment, model reasoning and application, etc. In some product forms, the computing device also supports model management, including but not limited to multi-type model management (supporting the management of multiple types of models such as discriminant and generative models), model version control (supporting the control of different model versions), model evaluation (based on model evaluation tools, evaluating the performance and effect of the model), etc. In other product forms, the computing device can also create applications based on models, provide API calling capabilities, and can call models to the created applications through API interfaces, while providing application management tools to achieve management and monitoring of applications.

[0134] Furthermore, the computing device can also include data management (supporting the creation and management of model tuning data sets), training center (providing rich training resources to help users learn and master AI technology), and basic management and control capabilities (providing enterprise-level basic management and control capabilities to ensure the security and efficient operation of the system). Through the above functions, a comprehensive, integrated AI development, training, deployment and application device is provided.

[0135] Among them, the memory can be used to store software programs and modules, such as program instructions / modules corresponding to the methods and devices in the embodiments of the present application, and the processor executes various functional applications and data processing by running the software programs and modules stored in the memory, that is, implementing the methods in the above embodiments. The memory may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory may further include a memory remotely arranged relative to the processor, and these remote memories may be connected to the terminal via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0136] The processor may call the executable program stored in the memory through the transmission device to execute the method described in any one of the above embodiments.

[0137] An embodiment of the present application may provide an electronic device. Fig.10 is a structural block diagram of an electronic device according to an embodiment of the present application. Fig.10 As shown, the electronic device may include: an input / output device 112 ; a memory 114 and a processor 116 , wherein the processor 116 is connected to the input / output device 112 and the memory 114 via a bus 118 .

[0138] Among them, the memory can be used to store software programs and modules, such as program instructions / modules corresponding to the methods and devices in the embodiments of the present application, and the processor executes various functional applications and data processing by running the software programs and modules stored in the memory, that is, implementing the methods in the above embodiments. The memory may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory may further include a memory remotely arranged relative to the processor, and these remote memories may be connected to the terminal via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0139] The processor may call the executable program stored in the memory through the transmission device to execute the method described in any one of the above embodiments.

[0140] Those skilled in the art will understand that Fig.10 The structure shown is for illustration only, and the computing device may also be a smart phone, tablet computer, PDA, mobile Internet device (MID), PAD and other terminal devices. Fig.10 The structure of the computing device is not limited. For example, the computing device 100 may also include Fig.10 More or fewer components (such as network interfaces, display devices, etc.) shown in the figure, or having Fig.10 Different configurations are shown.

[0141] A person of ordinary skill in the art can understand that all or part of the steps in the various methods of the above embodiments can be completed by instructing the hardware related to the terminal device through a program, and the program can be stored in a computer-readable storage medium, and the storage medium may include: a flash drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.

[0142] The embodiment of the present application further provides a computer-readable storage medium. Optionally, in this embodiment, the computer-readable storage medium can be used to store the program code executed by the method provided in the above embodiment.

[0143] Optionally, in this embodiment, the above storage medium may be located in a computing device.

[0144] Optionally, in this embodiment, the computer-readable storage medium is configured to store an executable program, and when the executable program is running, the device where the computer-readable storage medium is located is controlled to execute the method described in any one of the above embodiments.

[0145] The embodiments of the present application also provide a computer program product. Optionally, the computer program product may include a non-volatile computer-readable storage medium, which may be used to store a computer program, and when the computer program is executed by a processor, the method provided in the embodiments is implemented.

[0146] The embodiment of the present application further provides a computer program. Optionally, in this embodiment, when the computer program is executed by a processor, the method provided in the above embodiment is implemented.

[0147] In the above embodiments of the present application, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, please refer to the relevant description of other embodiments.

[0148] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of units or modules, which can be electrical or other forms.

[0149] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0150] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0151] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, server or network device, etc.) to execute all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, disk or optical disk, etc., which can store program code.

[0152] The above is only a preferred implementation of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.

Claims

1. A method for processing a model-based task, characterized in that: include: Determining target prompt information of a target text generation task, wherein the target prompt information is used to describe information required to complete the target text generation task; The target prompt information is input into a target model for processing to obtain a target text generation result of the target text generation task, wherein the target model is obtained by pre-training a natural language processing model based on a first sample data set and a second sample data set, the first sample data set is determined by unlabeled data, and the second sample data set is determined by supervised instruction data, the unlabeled data is text data that does not contain annotation information, and the supervised instruction data includes prompt information and text generation results.

2. The method according to claim 1, characterized in that: The target model is obtained by: Acquire the unlabeled data, and divide the unlabeled data into preset batches of first sample data, wherein the preset batches of first sample data constitute the first sample data set, and the unlabeled data are: unlabeled data related to the same type of task as the target text generation task, or unlabeled data in the field to which the target text generation task belongs; Acquire the supervised instruction data, divide the supervised instruction data into the preset batch of second sample data, wherein the preset batch of second sample data constitutes the second sample data set, and the supervised instruction data is: supervised instruction data related to the same type of task as the target text generation task, or supervised instruction data in the field to which the target text generation task belongs; Combining the first sample data and the second sample data of the same batch respectively to obtain the preset batch of sample data, wherein one batch of sample data includes one batch of first sample data and one batch of second sample data; The natural language processing model is further pre-trained according to the preset batch of sample data to obtain the target model.

3. The method according to claim 2, characterized in that Dividing the supervised instruction data into the preset batches of second sample data includes: Dividing the unlabeled data into the preset batches of unlabeled data; Perform word segmentation on any batch of unlabeled data, splice the word segmentation results, segment the splicing results according to a preset text size to obtain data segments corresponding to any batch, and determine the data segments corresponding to any batch as second sample data of any batch.

4. The method according to claim 2, characterized in that: Dividing the supervised instruction data into the preset batches of second sample data includes: In the case where the proportion of the number of the supervised instruction data in the total number of samples is less than a preset proportion, the supervised instruction data is sorted in order of size to obtain a sorting result, wherein the total number of samples refers to the sum of the number of the unlabeled data and the supervised instruction data, and the sorting result is the sorted supervised instruction data; The sorting result is divided into the preset batch of supervised instruction data, and the preset batch of supervised instruction data is determined as the preset batch of second sample data.

5. The method according to claim 2, characterized in that: Dividing the supervised instruction data into the preset batches of second sample data includes: In the case where the proportion of the number of the supervised instruction data in the total number of samples is greater than or equal to a preset proportion, the supervised instruction data is divided into different data combinations to obtain a data combination set, wherein the total number of samples refers to the sum of the number of the unlabeled data and the supervised instruction data, and the size of the data combination is less than or equal to a preset text size; The data in the data combinations in the data combination set are spliced ​​to obtain a splicing result set, the splicing result set is divided into the splicing results of the preset batches, and the splicing results of the preset batches are used to determine the second sample data of the preset batch, wherein one splicing combination in the splicing result set corresponds to one data combination.

6. The method according to claim 2, characterized in that The natural language processing model is further pre-trained according to the preset batch of sample data to obtain the target model, including: The natural language processing model is iteratively trained according to the preset batch of sample data, and the loss value of the trained model is calculated, until the loss value of the trained model is less than the preset loss value, or until a preset number of iterations is reached, and the trained model is determined as the target model, wherein, in the process of training the natural language processing model, the first sample data in the sample data in the same batch is input into the natural language processing model before the second sample data, and the loss value of the trained model includes a first loss value and a second loss value, the first loss value is determined by the difference between the predicted value and the actual value of the first sample data and a first loss weight, the second loss value is determined by the difference between the predicted value and the actual value of the second sample data and a second loss weight, and the second loss weight is greater than the first loss weight.

7. The method according to any one of claims 1 to 6, characterized in that Calculating the loss value of the trained model includes: Obtaining the output result of the self-attention sublayer of the trained model, wherein the self-attention sublayer blocks the sample data of the same batch according to a preset text size, and respectively calculates the causal mask matrix for the block results to obtain the output result of the self-attention sublayer; Obtaining the output result of the feedforward network sublayer of the trained model; The predicted value of the sample data is calculated according to the output result of the self-attention sublayer and the output result of the feedforward network sublayer, and the loss value is calculated according to the predicted value of the sample data and the actual value of the sample data.

8. A model training method, characterized in that: include: Acquire unlabeled data, and divide the unlabeled data into preset batches of first sample data, wherein the unlabeled data is: unlabeled data related to a target type of text generation task, or unlabeled data in a target field; Obtain supervised instruction data, and divide the supervised instruction data into the preset batch of second sample data, wherein the supervised instruction data is: supervised instruction data related to the text generation task of the target type, or supervised instruction data under the target domain; Combining the first sample data and the second sample data of the same batch respectively to obtain the preset batch of sample data, wherein one batch of sample data includes one batch of first sample data and one batch of second sample data; The natural language processing model is further pre-trained according to the preset batch of sample data to obtain a target model.

9. A method for processing a model-based task, characterized in that: include: The cloud server receives target prompt information of the target text generation task sent by the client, wherein the target prompt information is used to describe information required to complete the target text generation task; The cloud server processes the target prompt information through a target model to obtain a target text generation result of the target text generation task, wherein the target model is obtained by pre-training a natural language processing model based on a first sample data set and a second sample data set, the first sample data set is determined by unlabeled data, and the second sample data set is determined by supervised instruction data, the unlabeled data is text data that does not contain annotation information, and the supervised instruction data includes prompt information and a text generation result; The cloud server sends the text generation result to the client.

10. An electronic device, characterized in that: include: A memory storing an executable program; A processor, connected to the memory via a bus, and configured to run the program, wherein the program executes the method described in any one of claims 1 to 9 when running.

11. A computer-readable storage medium, characterized in that: The computer-readable storage medium includes a stored executable program, wherein when the executable program is executed, the device where the computer-readable storage medium is located is controlled to execute the method according to any one of claims 1 to 9.

12. A computer program product, characterized in that The invention comprises a computer program which, when executed by a processor, implements the method according to any one of claims 1 to 9.

Citation Information

Patent Citations

  • Large language model training method and device, equipment and medium

    CN116821684A

  • User loss prediction method and device, equipment, medium and program product

    CN117422490A

  • Model training sample processing method and device, electronic equipment and storage medium

    CN118153719A

  • Text classification model training method and device, equipment, medium and product

    CN118332124A

Cited By

  • Data transmission method and device, equipment, storage medium and program product

    CN120528959A

  • Security basic large model based on preference reinforcement learning and training method

    CN121074439A

  • A security and protection foundation big model based on preference reinforcement learning and a training method thereof

    CN121074439B