Large model training method, task processing method, equipment, medium and program product

By locking the first parameters of the large language model and using the extended network to learn relevant knowledge of multiple natural language processing tasks, the problems of knowledge forgetting and inefficiency in multi-task model training are solved, and a more efficient training process is achieved.

CN119358709BActive Publication Date: 2025-04-08ALIBABA CLOUD FEITIAN (HANGZHOU) CLOUD COMPUTING TECH CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202411942412.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-12-27
Publication Date
2025-04-08
Estimated Expiration
2044-12-27

AI Technical Summary

Technical Problem

When training a multi-task model, the model is prone to forget the knowledge learned before, and the training efficiency is low, and it takes a long time to fine-tune the full parameters.

Method used

By locking the first parameter of the large language model in the training round, the extended network learns the relevant knowledge of multiple natural language processing tasks, and only the second parameter of the extended network is updated to meet the training end condition.

Benefits of technology

The knowledge forgetting problem of large language models is avoided and training efficiency is improved. Only the second parameter of the extended network is updated instead of the full parameter.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119358709B_ABST
    Figure CN119358709B_ABST
Patent Text Reader

Abstract

The present application discloses a training method, a task processing method, a device, a medium and a program product of a large model, wherein the training method comprises: in any training round, calling a model to be trained to output multiple output texts based on multiple training texts, the model to be trained comprises a large language model and at least one extended network, any extended network is used to learn the relevant knowledge of multiple natural language processing tasks, and in any training round, the first parameter of the large language model is in a locked state; determining the target loss according to the target data, the target data comprises multiple output texts; updating the second parameter of at least one extended network according to the target loss, until it is determined that the training end condition is met, and a multi-task model is obtained. In the present application, the problem of knowledge forgetting is avoided, and the training efficiency of the multi-task model is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of artificial intelligence technology, and specifically to a large model training method, task processing method, equipment, medium and program product. Background Art

[0002] With the continuous increase in user demand and the continuous expansion of service types, it is necessary to use the same large model to handle multiple tasks, that is, it is necessary to train a multi-task model. At present, when training a multi-task model, the training data of multiple tasks is often matched and the full parameters of the model are fine-tuned. There are at least the following problems in the training method of this multi-task model: the problem of knowledge forgetting, that is, when the model learns the relevant knowledge of a new task, it is easy to forget the previously learned knowledge. The efficiency problem, that is, it takes a long time and the training efficiency is low. Summary of the invention

[0003] In response to the above-mentioned technical problems, the present application provides a large model training method, task processing method, equipment, medium and program product.

[0004] The first aspect of the present application provides a large model training method, the method comprising:

[0005] In any training round, calling a model to be trained to output multiple output texts based on multiple training texts, the model to be trained includes a large language model and at least one extended network, any extended network is used to learn relevant knowledge of multiple natural language processing tasks, and the first parameter of the large language model in the training round is in a locked state;

[0006] determining a target loss based on target data, the target data including the plurality of output texts;

[0007] The second parameter of the at least one extended network is updated according to the target loss until it is determined that the training end condition is met, thereby obtaining a multi-task model.

[0008] A second aspect of the present application provides a task processing method, the method comprising:

[0009] Acquire text data of a target task, where the target task is any one of a plurality of natural language processing tasks;

[0010] A multi-task model is called to process the text data to obtain output text, wherein the multi-task model is trained according to the training method provided in the first aspect.

[0011] The third aspect of the present application provides a large model training device, the device comprising:

[0012] A training module, used for calling a model to be trained to output multiple output texts based on multiple training texts in any training round, wherein the model to be trained includes a large language model and at least one extended network, wherein any extended network is used to learn relevant knowledge of multiple natural language processing tasks, and wherein a first parameter of the large language model in the training round is in a locked state;

[0013] A first determination module, configured to determine a target loss according to target data, wherein the target data includes the plurality of output texts;

[0014] An updating module is used to update the second parameter of the at least one extended network according to the target loss until it is determined that the training end condition is met to obtain a multi-task model.

[0015] A fourth aspect of the present application provides a computing device, the device comprising:

[0016] An acquisition module, used to acquire text data of a target task, wherein the target task is any one of a plurality of natural language processing tasks;

[0017] A processing module is used to call a multi-task model to process the text data to obtain output text, and the multi-task model is trained according to the training method provided in the first aspect.

[0018] A fifth aspect of the present application provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the method described in the first aspect above.

[0019] A sixth aspect of the present application provides a computer-readable storage medium having a computer program stored thereon, wherein the program is executed by a processor to implement the method as described in the first aspect above.

[0020] The seventh aspect of the present application provides a computer program product, including a computer program, wherein the computer program is executed by a processor to implement the method described in the first aspect above.

[0021] This application has at least the following beneficial effects or advantages:

[0022] In an embodiment of the present application, in any training round, a model to be trained including a large language model and at least one extended network is trained, and during the training process, since the first parameter of the large language model is in a locked state, the model to be trained can learn relevant knowledge of multiple natural language processing tasks through the extended network, which not only avoids the knowledge forgetting problem of the large language model, but also only needs to update the second parameter of the extended network instead of updating all parameters, thereby greatly improving the training efficiency.

[0023] The above description is only an overview of the technical solution of the present application. In order to more clearly understand the technical means of the present application, it can be implemented in accordance with the contents of the specification. In order to make the above and other purposes, features and advantages of the present application more obvious and easy to understand, the specific implementation methods of the present application are listed below. BRIEF DESCRIPTION OF THE DRAWINGS

[0024] In the accompanying drawings, unless otherwise specified, the same reference numerals throughout the multiple drawings represent the same or similar parts or elements. These drawings are not necessarily drawn to scale. It should be understood that these drawings only depict some embodiments according to the present application and should not be regarded as limiting the scope of the present application.

[0025] Figure 1 A schematic diagram of an application scenario of a multi-task model training method provided in an embodiment of the present application;

[0026] Figure 2 A first flow chart of a large model training method provided in an embodiment of the present application;

[0027] Figure 3 A second flow chart of a large model training method provided in an embodiment of the present application;

[0028] Figure 4 A third flow chart of a large model training method provided in an embodiment of the present application;

[0029] Figure 5 A schematic diagram of the model structure provided in the embodiment of the present application;

[0030] Figure 6 A fourth flow chart of a large model training method provided in an embodiment of the present application;

[0031] Figure 7 A fifth flow chart of a large model training method provided in an embodiment of the present application;

[0032] Figure 8 A sixth flow chart of a large model training method provided in an embodiment of the present application;

[0033] Fig. 9 A flowchart of a task processing method provided in an embodiment of the present application;

[0034] Fig.10 A schematic diagram of the structure of a large-scale model training device provided in an embodiment of the present application;

[0035] Fig.11 A schematic diagram of the structure of a computing device provided in an embodiment of the present application;

[0036] Fig.12A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0037] In the following, only some exemplary embodiments are briefly described. As those skilled in the art will appreciate, the described embodiments may be modified in various ways without departing from the concept or scope of the present application. Therefore, the drawings and descriptions are considered to be exemplary in nature and not restrictive.

[0038] To facilitate understanding of the technical solutions of the embodiments of the present application, the following describes the related technologies of the embodiments of the present application. The following related technologies can be combined with the technical solutions of the embodiments of the present application as optional solutions, and they all belong to the protection scope of the embodiments of the present application.

[0039] The following terms will be used in the following text:

[0040] Large Language Model (LLM): A language model with a large number of parameters. Usually based on deep learning architectures such as Transformer, they learn language structures and patterns through unsupervised pre-training on massive text data. LLM is able to perform a variety of natural language processing tasks such as text generation, question answering, translation, etc., without the need for additional task-specific training.

[0041] Multi-task Learning (MTL): A machine learning technique that processes multiple related tasks simultaneously in order to improve performance and efficiency by sharing representations, features, or models. Unlike single-task learning, multi-task learning attempts to exploit the correlation between tasks to achieve better generalization capabilities on certain tasks.

[0042] Model fine-tuning: refers to further training a pre-trained model on a small amount of domain-specific data to improve the model's performance on a specific task. This process usually includes adjusting the model's parameters so that it can better adapt to new data distributions and task requirements. Fine-tuning can significantly reduce the requirements for large-scale training data and computing resources, while retaining the rich knowledge learned by the pre-trained model, making it more effective on new tasks.

[0043] With the continuous development of artificial intelligence technology, large models are widely used in various scenarios to perform various tasks, such as natural language to SQL (NL2SQL) tasks, multi-round rewriting tasks, etc. However, deploying a model for each task will greatly increase the model deployment load. Therefore, it is necessary to train a model that can handle multiple tasks at the same time, that is, to train a multi-task model. At present, in the training process of multi-task models, the training data of multiple tasks are matched and the full parameters of the model are fine-tuned. Therefore, there are at least the following problems: knowledge forgetting problem, that is, when the model learns the relevant knowledge of new tasks, it is easy to forget the previously learned knowledge. Efficiency problem, that is, fine-tuning the full parameters of the model takes a long time and the training efficiency is low; and because the amount of data for multiple tasks will increase exponentially, it is necessary to use appropriate fine-tuning methods to shorten the time and cost of fine-tuning training. The problem of imbalance between tasks and data, that is, the influence between tasks may make the model perform better on some tasks and worse on other tasks. At the same time, the imbalance of data volume will also cause the model to be biased towards models with large data volume.

[0044] Based on this, the present application embodiment provides a large model training method. Figure 1 Schematic diagram of an application scenario of a large model training method provided in an embodiment of the present application. Figure 1 As shown, the scenario includes a training device and a model to be trained.

[0045] The model to be trained includes a pre-trained large language model and at least one extended network. Any extended network is used to learn relevant knowledge of multiple natural language processing tasks, and any extended network may include multiple processing layers. For the specific structure of the model to be trained, please refer to the relevant description below, and the repetition will not be repeated here.

[0046] The training device can be a terminal device or a server. The terminal device can be a mobile phone, a tablet computer, a desktop computer, a portable notebook, a home appliance, a car terminal, etc. The server can be an independent server such as a physical server and a cloud server, or it can be a server cluster composed of multiple servers. The training device can maintain initialization strategies, training strategies, loss determination strategies, parameter adjustment strategies, etc. Among them, the initialization strategy is used to indicate that the update state of the first parameter of the large language model is configured to be a locked state, and the second parameter of at least one extended network is initialized. The training strategy is used to indicate that in any training round, the model to be trained is called to output multiple output texts based on multiple training texts. The loss determination strategy is used to indicate that the target loss is determined according to the target data, and the target data includes multiple output texts. The parameter adjustment strategy is used to indicate that the second parameter is updated according to the target loss until it is determined that the training end condition is met to obtain a multi-task model.

[0047] Figure 1 In the example, the training device is an independent physical server. It should be understood that Figure 1 The illustration is merely a schematic representation of the application scenario of the large model training method involved in the present application and does not constitute a limitation to the technical solution of the present application.

[0048] It should be noted that the above application scenarios or application examples provided in the embodiments of the present application are for ease of understanding, and the embodiments of the present application do not specifically limit the application of the technical solution. In addition, 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 need to 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.

[0049] The technical solution of the present application and how the technical solution of the present application solves the above-mentioned technical problems are described in detail below with specific embodiments. The several specific embodiments listed can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. The embodiments of the present application will be described in detail below with reference to the accompanying drawings.

[0050] Figure 2 A flowchart of a large model training method provided in an embodiment of the present application, Figure 2 The method shown can be Figure 1 The training equipment in Figure 2 As shown, the method includes the following steps 101-103.

[0051] Step 101, in any training round, calling a model to be trained to output multiple output texts based on multiple training texts, the model to be trained includes a large language model and at least one extended network, any extended network is used to learn relevant knowledge of multiple natural language processing tasks, and the first parameter of the large language model in any training round is in a locked state.

[0052] Step 102, determining a target loss according to target data, where the target data includes a plurality of output texts.

[0053] Step 103: update the second parameter of at least one extended network according to the target loss until it is determined that the training end condition is met to obtain a multi-task model.

[0054] In order to inject the relevant knowledge of different natural language processing tasks into the same model to obtain a multi-task model, in one or more embodiments of the present application, a large language model is pre-trained, and a model to be trained is constructed based on the large language model and at least one extended network, and the model to be trained is fine-tuned to obtain a multi-task model. In order to prevent the large language model from forgetting the knowledge learned during the pre-training process during the fine-tuning training process, in one or more embodiments of the present application, the first parameter of the large language model is frozen so that the first parameter is in a locked state, and the relevant knowledge of multiple natural language processing tasks is learned through the extended network during the fine-tuning training process, and the second parameter of the extended network is tuned.

[0055] Among them, the multiple natural language processing tasks can be any multiple of text classification, sentiment analysis, syntactic analysis, text generation, information extraction, etc., which is not specifically limited in this application. The multiple training texts may include training texts corresponding to each natural language processing task, and may also include training texts corresponding to some natural language processing tasks. For any training text, the training model to be trained first divides the training text into multiple characters (tokens), and any character can be a word, a word, or a phrase. For each character, the first identifier corresponding to the character is obtained in the preset mapping table. The length of each first identifier is aligned to the preset length, and the first identifier of each preset length is encoded to obtain the corresponding first vector. According to each first vector, the probability distribution of the first character of the output text is first predicted, and the probability distribution includes the probability that the first character is each preset character in the preset mapping table. The preset character corresponding to the maximum probability is determined as the first character, and the second identifier corresponding to the first character is output, and then according to each first vector and the second identifier, the second identifier of the second character is output in the above manner until the second identifier of the last character of the output text is obtained. The characters corresponding to each second identifier are obtained from the preset mapping table, and the corresponding output text is obtained according to each obtained character.

[0056] In some implementations, a batch size of 16 may be used in the above training process, that is, in any training round, the number of training texts is 16. A warmup ratio of 10% may also be set. The initial learning rate and cosine learning rate scheduler are used. The second parameter and task weight are updated using the adaptive moment estimation optimizer (Adam optimizer). BF16 (Brain Floating Point, 16-bit brain floating point) mixed precision and 0.1 weight decay are used. In order to increase the training speed, the FlashAttention mechanism can also be used. The FlashAttention mechanism is a new type of attention algorithm that is fast and memory-efficient. It should be pointed out that the aforementioned parameters are not limited to this and can be set as needed in actual applications.

[0057] Therefore, in any training round, the model to be trained, which includes a large language model and at least one extended network, is trained. During the training process, since the first parameter of the large language model is in a locked state, the model to be trained can learn relevant knowledge of multiple natural language processing tasks through the extended network, which not only avoids the knowledge forgetting problem of the large language model, but also only needs to update the second parameter of the extended network instead of updating all parameters. Therefore, the training efficiency is greatly improved.

[0058] In order to improve the performance of the model to be trained in multiple natural language processing tasks, in some implementations, a target training set is first constructed based on the initial training set corresponding to each natural language processing task. Figure 3 As shown, before step 101, the following steps 100 may also be included:

[0059] Step 100, obtaining training texts that meet the second preset condition from multiple initial training sets to obtain a target training set, the multiple initial training sets correspond one-to-one to multiple natural language processing tasks, and any initial training set includes multiple training texts corresponding to the natural language processing tasks.

[0060] In some embodiments, multiple corresponding training texts can be obtained in advance for each natural language processing task to obtain an initial training set for each natural language processing task. In order to enrich the knowledge system of the model to be trained and enable the model to be trained to improve the knowledge that it is currently not good at, in some embodiments, training texts that meet the second preset condition are obtained from the initial training set to obtain a target training set. The second preset condition is used to characterize the accuracy of the processing results of the large language model on the training text. Specifically, Figure 4 As shown, step 100 may include the following steps 1001 to 1003:

[0061] Step 1001, for an initial training set of any natural language processing task among multiple natural language processing tasks, call a large language model to process each training text in the initial training set to obtain each predicted text corresponding to each training text.

[0062] In some embodiments, for the initial training set of any natural language processing task, each training text in the initial training set can be simultaneously input into the large language model to obtain the predicted text corresponding to each training text. In some embodiments, part of the training text in the initial training set can also be input into the large language model in batches to obtain the predicted text corresponding to the corresponding training text. This application does not make specific limitations on this, and it can be set as needed in actual applications.

[0063] Step 1002: for any training text, determine the similarity between the predicted text corresponding to the training text and the target output text corresponding to the training text, wherein the label of the training text includes the target output text corresponding to the training text.

[0064] In some embodiments, for any training text, the BLUE (Bilingual Evaluation Understudy) value between the predicted text corresponding to the training text and the target output text corresponding to the training text can be counted, and the similarity between the predicted text and the target output text can be determined by the BLUE value. The BLUE value ranges from 0 to 1, and the larger the BLUE value, the higher the similarity between the predicted text and the target output text. The specific statistical method of the BLUE value can refer to the relevant technology, and is not specifically limited in this application.

[0065] It should be noted that the similarity between the predicted text and the target output text is not limited to the statistical BLUE value, and can also be calculated by calculating the cosine similarity, Euclidean distance, Hamming distance, etc. between the predicted text and the target output text.

[0066] Step 1003: determine each training text corresponding to the target similarity as a target training set, where the target similarity is a similarity less than a first similarity threshold.

[0067] Specifically, for any similarity, it is determined whether the similarity is less than a first similarity threshold, and if so, the similarity is determined as a target similarity, and the training texts corresponding to each target similarity are determined as a target training set.

[0068] If the similarity is less than the first similarity threshold, it indicates that there is a large difference between the predicted text and the target output text, that is, the model does not have sufficient knowledge of the corresponding training text, the processing capability is still at a relatively weak stage, and the accuracy of the processing result is low. In the embodiment of the present application, by determining the training text corresponding to the target similarity less than the first similarity threshold as the target training set, and training the model to be trained based on the target training set, while ensuring that the model to be trained can learn the relevant knowledge of multiple natural language processing tasks, it learns the knowledge that it currently does not have sufficient knowledge to enrich the knowledge system of the model and improve the robustness and accuracy of the model.

[0069] It should be pointed out that the process of obtaining training texts that meet the second preset condition is not limited to the above method. In some embodiments, after obtaining the predicted texts corresponding to the training texts, for any training text, the predicted text corresponding to the training text is scored according to the target output text corresponding to the training text. The higher the score, the higher the accuracy of the predicted text. The training text corresponding to the score less than the score threshold is determined as the training text that meets the second preset condition.

[0070] Corresponding to step 100, Figure 3 As shown, step 101 may include the following steps 1011:

[0071] Step 1011, in any training round, multiple training texts are obtained from the target training set, and the model to be trained is called to output multiple output texts based on the multiple training texts; the model to be trained includes a large language model and at least one extended network, any extended network is used to learn relevant knowledge of multiple natural language processing tasks, and the first parameter of the large language model is in a locked state.

[0072] It needs to be emphasized that Figure 3 and Figure 4 For illustration only, step 100 is performed only before the first training round, rather than in every training round.

[0073] By obtaining training texts that meet the second preset condition from multiple initial training sets corresponding to multiple natural language processing tasks, a target training set is obtained, and the model to be trained is trained based on the target training set. This enables the model to be trained to learn more knowledge that it currently does not fully master, thereby helping to improve the robustness and accuracy of the model to be trained.

[0074] In order to avoid the problem of knowledge forgetting and task imbalance of a large language model, in some implementations, when the training round is the first training round, before calling the model to be trained to output multiple output texts based on multiple training texts, the method may further include the following steps 1003 and 1004:

[0075] Step 1003, calling a preset function interface, adding at least one extended network to the large language model obtained by pre-training, and obtaining a model to be trained.

[0076] Specifically, when the training round is the first training round, before calling the model to be trained to output multiple output texts based on multiple training texts, first call the preset function interface to add at least one extended network to the large language model obtained by pre-training to obtain the model to be trained.

[0077] In some implementations, the large language model includes a plurality of connected decoding blocks. Accordingly, adding at least one extended network to the pre-trained large language model may include the following steps A:

[0078] Step A: divide multiple decoding blocks in the large language model into at least one block combination; for any block combination, add at least one extended network at a preset position in the block combination.

[0079] As an example, Figure 5 As shown in the figure, the large language model includes an input layer, M*N decoding blocks and an output layer. Each M decoding block is divided into a block combination, totaling N block combinations. And P extended networks are added after the last decoding block in each block combination. Among them, M, N and P are all integers greater than or equal to 1, for example, M=4, N=7, P=1.

[0080] It should be noted that the preset position is not limited to the position in the above example, and it can be set according to the actual application. The method of adding an extended network to the large language model is not limited to the above step A, and multiple extended networks can be added only after a decoding block of the large language model.

[0081] By adding at least one extended network to the large language model, relevant knowledge of multiple natural language processing tasks can be learned through the extended network during the training process, thereby avoiding the knowledge forgetting problem of the large language model.

[0082] Step 1004, configuring the update state of the first parameter of the large language model to be a locked state, and initializing the second parameter of the extended network and multiple task weights, where the multiple task weights correspond one-to-one to the multiple natural language processing tasks.

[0083] In some embodiments, the target attribute of the first parameter may be configured as the first data to configure the update state of the first parameter to be a locked state. The target attribute may be a requires_grad attribute, and the first data may be false. In other embodiments, a context manager may be used to configure the update state of the first parameter to be a locked state. This is not specifically limited in the present application.

[0084] In some embodiments, any decoding block of the large language model includes multiple first processing layers, and the structure of any extended network is the same as that of the decoding block, that is, the number of network layers of any extended network is the same as that of the decoding block. The specific structure of the decoding block can refer to the relevant technology, which will not be described in detail in this application. In order to achieve the identity mapping during the training process, the aforementioned initialization of the second parameter may include the following steps B:

[0085] Step B, initialize the parameters of the second processing layer in the extended network to zero; for any extended layer, determine the processing layer in the decoding block corresponding to the extended layer, the position of the extended layer in the extended network is the same as the position of the first processing layer in the decoding block, and the extended layer is the layer in the extended network except the second processing layer; initialize the parameters of the extended layer to the parameters of the first processing layer.

[0086] That is to say, the extended network includes a second processing layer and an extended layer. In some embodiments, the second processing layer can be a linear layer. By initializing the parameters of the second processing layer to zero and initializing the parameters of the extended layer to the parameters of the corresponding first processing layer, the identity mapping can be achieved through the second processing layer, that is, the data is transferred from the input to the output unchanged. Since the identity mapping does not introduce additional computational complexity, the training efficiency can be improved, and the extended network will not immediately affect the output of the large language model. At the same time, as the training progresses, the parameters of the extended layer will gradually adjust to meet the needs of multiple natural language processing tasks, so that the knowledge of multiple natural language processing tasks can be gradually integrated into the model.

[0087] Furthermore, in order to avoid task imbalance, initializing the weights of multiple tasks may be initializing the weight of each task to 1.

[0088] Therefore, by adding the extended network to the large language model before the first training round, configuring the update state of the first parameter of the large language model to be locked, and initializing the second parameter and multiple task weights, the relevant knowledge of multiple natural language processing tasks can be learned through the extended network during the training process, while avoiding the problem of knowledge forgetting of the large language model.

[0089] In order to update the second parameter on the basis of ensuring task balance, in some implementations of the present application, the target data also includes multiple task weights, and the first loss corresponding to each natural language processing task is determined according to the output text, and the target loss is determined according to each first loss and each task weight. Figure 6 As shown, step 102 may include the following steps 1021 to 1023:

[0090] Step 1021, divide the multiple output texts into multiple text sets, and the multiple text sets correspond to the multiple natural language processing tasks one by one.

[0091] In some embodiments, the task type corresponding to the input text corresponding to the output text is determined as the task type corresponding to the output text, and the output text is divided into multiple text sets according to the task type of each output text, and the multiple text sets correspond one-to-one to the multiple task types, that is, the multiple text sets correspond one-to-one to the multiple natural language processing tasks.

[0092] Step 1022, for any natural language processing task, determine the first loss corresponding to the natural language processing task according to the text set corresponding to the natural language processing task and the task weight corresponding to the natural language processing task.

[0093] Specifically, Figure 7 As shown, step 1022 may include the following steps 1022-1 to 1022-3:

[0094] Step 1022-1, for any output text in the text set corresponding to the natural language processing task, determine multiple probabilities corresponding to the output text, the multiple probabilities correspond one-to-one to multiple target characters in the output text, any probability is the maximum probability in the probability distribution corresponding to the corresponding target character, the probability distribution corresponding to any target character includes the probability that the character is each preset character, and the target character is a character that meets the first preset condition.

[0095] In one embodiment, the first preset condition can be used to constrain the length of the identifier corresponding to the character. Accordingly, before determining multiple probabilities corresponding to the output text, the method also includes: for any character in the output text, determining the target identifier corresponding to the character in the preset mapping table; if it is determined that the length of the target identifier is not greater than the preset length, the character corresponding to the target identifier is determined as the target character.

[0096] According to the above description, the model to be trained determines each character in the output text one by one in the process of generating the output text, and when determining any character, generates a probability distribution corresponding to the character, the probability distribution includes the probability that the any character is each preset character in the preset mapping table, and the preset character corresponding to the maximum probability in the probability distribution is determined as the any character. Accordingly, in step 1022-1, for any character in any output text, the target identifier corresponding to the any character is obtained from the preset mapping table, if it is determined that the length of the target identifier is not greater than the preset length, the character corresponding to the target identifier is determined as the target character, and the maximum probability is obtained from the probability distribution corresponding to the target character; thereby, multiple probabilities corresponding to multiple target characters in the any output text (i.e., multiple maximum probabilities) can be obtained.

[0097] Since the training model needs to align the identifier with a length greater than the preset length to the preset length when generating the output text, part of the content in the identifier will be discarded. At this time, the identifier can also be called an invalid token. The target character is the character corresponding to the target identifier whose length is not greater than the preset length. Since the target identifier is complete and no content is discarded, it can also be called a valid token.

[0098] Step 1022-2, determining the sub-loss corresponding to the output text according to the multiple probabilities corresponding to the output text.

[0099] In some implementations, for any probability of each output text, the negative logarithm with base 10 corresponding to the probability can be determined, and the negative logarithms corresponding to the probabilities can be added to obtain the sub-loss corresponding to the output text.

[0100] That is, the sub-loss can be expressed as: .

[0101] in, represents sub-loss; Indicates Valid token, i.e. target characters; Indicates The first natural language processing task The total number of valid tokens corresponding to the training text, that is, The first natural language processing task The total number of target characters in the output text corresponding to the training text; Indicates The first natural language processing task The training text corresponds to Valid token, i.e. The first natural language processing task The training text corresponds to target characters; Indicates The first natural language processing task The training text corresponds to The probability corresponding to a valid token (i.e., the aforementioned maximum probability), i.e., The first natural language processing task The training text corresponds to The probability corresponding to the target character (i.e. the aforementioned maximum probability); Represents the negative logarithm to base 10.

[0102] Step 1022-3, determine the first loss according to the sub-loss corresponding to each output text in the text set and the task weight corresponding to the natural language processing task.

[0103] Specifically, for a text set corresponding to any natural language processing task, the sub-losses corresponding to each output text in the text set are added to obtain a first result; the total number of target characters corresponding to each output text is added to obtain a second result; the square of the task weight corresponding to the natural language processing task is determined to obtain a square value; the logarithm of the task weight of any natural language processing task with base 10 is determined to obtain a target logarithm; the second result is multiplied by the square value to obtain a third result; the first result is divided by the third result to obtain a fourth result; the fourth result is added to the target logarithm to obtain the first loss.

[0104] That is, the first loss can be expressed as: 。

[0105] in, Indicates the first loss; Represents the sub-loss, that is, the aforementioned ; Indicates The task weight of each natural language processing task; Indicates The first natural language processing task training texts; Indicates The total number of training texts corresponding to the natural language processing tasks; Indicates The first natural language processing task The total number of valid tokens corresponding to the training text, that is, The first natural language processing task The total number of target characters in the output text corresponding to the training text; It represents the logarithm with base 10.

[0106] Step 1023: Determine the target loss according to the first loss corresponding to each natural language processing task.

[0107] Specifically, the average value of the first loss corresponding to each natural language processing task is determined to obtain the target loss. In other words, the target loss can be expressed as:

[0108] .in, represents the total number of natural language processing tasks, Indicates Natural language processing tasks, Represents the first loss, namely the aforementioned .

[0109] Therefore, when determining the target loss, the number of target characters corresponding to the training text (i.e., the number of valid tokens) is weighted according to the task weight instead of the number of samples. This avoids the model's preference for tasks with larger data volumes and solves the problem of task imbalance caused by an imbalance in the number of samples, that is, the model performs better on some tasks but worse on other tasks.

[0110] In some embodiments, the training text may also carry a label, which includes a standard output text corresponding to the training text. Accordingly, the aforementioned determination of the first loss corresponding to the natural language processing task may also be for any output text in the text set corresponding to the natural language processing task, determining the similarity between the output text and the corresponding standard output text, determining the average value of the similarities corresponding to each output text in the text set corresponding to the natural language processing task, multiplying the average value of the similarities by the task weight, and obtaining the first loss corresponding to the natural language processing task.

[0111] Furthermore, in order to avoid the aforementioned task imbalance problem, in one or more embodiments of the present application, after determining the target loss based on multiple task weights, it also includes: updating the multiple task weights according to the target loss.

[0112] By updating the task weights according to the target loss, the task weights can be continuously optimized during the training process, ensuring task balance and avoiding the situation where the multi-task model performs better on some tasks and worse on other tasks.

[0113] In order to ensure the performance of the trained multi-task model, in some implementations, the target training set is used to perform model training for multiple training cycles, and the candidate second parameters corresponding to each training cycle are obtained, and the target second parameters are determined from the candidate second parameters. Specifically, Figure 8 As shown, step 103 may include the following steps 1031 to 1034:

[0114] Step 1031: Update a second parameter of at least one extended network and a plurality of task weights according to the target loss.

[0115] Specifically, the gradient of each second parameter and the gradient of each task weight are calculated according to the target loss, and the second parameter is updated according to the gradient of the second parameter, and the task weight is updated according to the gradient of the task weight. The calculation method of the gradient of the second parameter and the gradient of the task weight can refer to the relevant technology, and this application does not make specific limitations on this.

[0116] Step 1032: If it is determined that the current training cycle is over, the current second parameter is determined as a candidate second parameter corresponding to the current training cycle. In any training cycle, each training text in the target training set participates in one training.

[0117] Among them, one training cycle is an epoch, which refers to the process in which the model traverses and learns the target training set once. That is to say, in any training cycle, each training text in the target training set participates in one training.

[0118] In order to avoid the aforementioned data imbalance problem, in one or more embodiments of the present application, when obtaining multiple training texts from the target training set for the current training round, a non-repetitive sampling mechanism is adopted, and it is ensured that all samples in the target training set are sampled once. When all samples in the target training set are sampled once, it can be determined that each training text in the target training set has participated in one training, and the current second parameter is determined as the candidate second parameter corresponding to the target training set. Then, the target training set is used for training in the next training cycle until a preset number of candidate second parameters are obtained.

[0119] Step 1033: If the number of candidate second parameters reaches a preset number, it is determined that the training end condition is met, and a target second parameter that meets a third preset condition is determined among the preset number of candidate second parameters.

[0120] Specifically, when the number of candidate second parameters reaches a preset number, it indicates that the training has been performed for a preset number of training cycles, then it is determined that the training end condition is met, and a target second parameter that meets the third preset condition among the candidate second parameters is determined. As an example, the preset number is 5, that is, the model is trained for 5 training cycles using the target training set to obtain 5 candidate second parameters.

[0121] Among them, the third preset condition can be used to characterize the accuracy of the candidate second parameter, that is, determining the target second parameter that meets the third preset condition among the preset number of candidate second parameters, which may include: for any candidate second parameter, using the test text to verify the model to be trained corresponding to the candidate second parameter, and obtaining a verification result, the verification result characterizing the accuracy of the processing result of the test text by the model to be trained; determining the candidate second parameter corresponding to the maximum accuracy as the target second parameter. It can be understood that the higher the accuracy of the processing result of the test text by the model to be trained, the higher the accuracy of the corresponding candidate second parameter, therefore, determining the candidate second parameter corresponding to the maximum accuracy as the target second parameter ensures the accuracy of the multi-task model.

[0122] In some implementations, the target training set may be further divided into a training set and a test set. Accordingly, in step 101, the training text in the training set may be used to train the model to be trained, and in step 1033, the test text in the test set may be used to verify the model to be trained corresponding to the candidate second parameter.

[0123] Furthermore, using the test text to verify the model to be trained corresponding to the candidate second parameter to obtain the verification result may include: inputting at least one test text into the model to be trained corresponding to the first parameter and the candidate second parameter to obtain the prediction result; determining the similarity between the predicted text and the target output text in the label of the test text, if the similarity is greater than the second similarity threshold, determining that the corresponding predicted text is predicted correctly; if the similarity is not greater than the second similarity threshold, determining that the corresponding predicted text is predicted incorrectly. Counting the first number of predicted texts that are predicted correctly, and dividing the first number by the total number of test texts to obtain the accuracy corresponding to the corresponding candidate second parameter. And, determining the candidate second parameter corresponding to the maximum accuracy as the target second parameter.

[0124] Step 1034: determine the to-be-trained model corresponding to the first parameter and the target second parameter as a multi-task model.

[0125] Therefore, by performing model training for multiple training cycles, multiple candidate second parameters are obtained, and each candidate second parameter is tested, thereby ensuring the accuracy of the target second parameter and further ensuring the accuracy of the multi-task model.

[0126] Corresponding to the embodiment of the aforementioned large model training method, the present application also provides a task processing method, Fig. 9 A flowchart of a task processing method provided in an embodiment of the present application, Fig. 9 The method shown can be executed by a task processing device. Fig. 9 As shown, the method includes the following steps 201 and 202.

[0127] Step 201, obtaining text data of a target task, where the target task is any one of a plurality of natural language processing tasks.

[0128] In some implementations, the task processing device may receive text data of the target task input by a user, or may receive text data of the target task sent by other devices. The method for obtaining the text data of the target task is not specifically limited in this application.

[0129] Step 202: Call the multi-task model to process the text data to obtain output text.

[0130] Among them, the multi-task model is trained according to the training method of the multi-task model provided in any of the aforementioned embodiments. For details, please refer to the relevant description in the previous text, and the repeated parts will not be repeated here.

[0131] The multi-task model used in the task processing method provided in the embodiment of the present application is obtained by training a model to be trained that includes a large language model and at least one extended network. During the training process, since the first parameter of the large language model is in a locked state, the model to be trained can learn the relevant knowledge of multiple natural language processing tasks through the extended network, avoiding the problem of knowledge forgetting of the large language model and improving the accuracy of the multi-task model. Furthermore, the target task is processed based on the multi-task model to ensure the accuracy of the processing results.

[0132] Corresponding to the aforementioned embodiment of the large model training method, the present application also provides an embodiment of the large model training device. Fig.10 is a schematic diagram of a large model training device according to an exemplary embodiment. The device can be configured in Figure 1 In the training equipment shown. Fig.10 As shown, the training device of the large model includes:

[0133] The training module 301 is used to call the model to be trained to output multiple output texts based on multiple training texts in any training round, the model to be trained includes a large language model and at least one extended network, any extended network is used to learn relevant knowledge of multiple natural language processing tasks, and the first parameter of the large language model in the training round is in a locked state.

[0134] The first determination module 302 is used to determine the target loss according to the target data, where the target data includes a plurality of output texts.

[0135] The updating module 303 is used to update the second parameter of at least one extended network according to the target loss until it is determined that the training end condition is met to obtain a multi-task model.

[0136] In some implementations, the device further includes: an adding module and an initialization module.

[0137] An adding module is used for, when the training round is the first training round, before the training module 301 calls the model to be trained to output multiple output texts based on multiple training texts, calling a preset function interface to add at least one extended network to the large language model obtained by pre-training to obtain the model to be trained;

[0138] An initialization module is used to configure the update state of the first parameter to a locked state and initialize the second parameter and multiple task weights when the training round is the first training round and before the training module 301 calls the model to be trained to output multiple output texts based on multiple training texts. The multiple task weights correspond one-to-one to multiple natural language processing tasks.

[0139] In some implementations, the large language model includes a plurality of connected decoding blocks, and accordingly, the adding module is specifically used for:

[0140] The plurality of decoding blocks are divided into at least one block group.

[0141] For any block combination, at least one extended network is added at a preset position in the block combination.

[0142] In some implementations, any decoding block includes a plurality of first processing layers, and the number of network layers of any extended network is the same as the number of network layers of the decoding block. Accordingly, the initialization module is specifically used to:

[0143] Initialize the parameters of the second processing layer in the extended network to zero.

[0144] For any extended layer, determining a first processing layer in a decoding block corresponding to the extended layer, the position of the extended layer in the extended network being the same as the position of the first processing layer in the decoding block, and the extended layer being a layer in the extended network other than the second processing layer;

[0145] Initialize the parameters of the expansion layer to the parameters of the first processing layer.

[0146] In some implementations, the first determining module 302 is specifically configured to:

[0147] The multiple output texts are divided into multiple text sets, and the multiple text sets correspond to the multiple natural language processing tasks one by one.

[0148] For any natural language processing task, a first loss corresponding to the natural language processing task is determined according to a text set corresponding to the natural language processing task and a task weight corresponding to the natural language processing task.

[0149] The target loss is determined according to the first loss corresponding to each natural language processing task.

[0150] In some implementations, the first determining module 302 is further specifically configured to:

[0151] For any output text in a text set corresponding to a natural language processing task, multiple probabilities corresponding to the output text are determined, and the multiple probabilities correspond one-to-one to multiple target characters in the output text. Any probability is the maximum probability in the probability distribution corresponding to the corresponding target character. The probability distribution corresponding to any target character includes the probability that the character is each preset character. The target character is a character that satisfies a first preset condition, and the first preset condition is used to constrain the length of the identifier corresponding to the character.

[0152] According to multiple probabilities, the sub-loss corresponding to the output text is determined.

[0153] The first loss is determined according to the sub-loss corresponding to each output text in the text set and the task weight corresponding to the natural language processing task.

[0154] In some implementations, the first determining module 302 is further configured to:

[0155] Before determining a plurality of probabilities corresponding to the output text, for any character in the output text, a target identifier corresponding to the character in a preset mapping table is determined.

[0156] If it is determined that the length of the target identifier is not greater than the preset length, the character corresponding to the target identifier is determined as the target character.

[0157] In some implementations, the updating module 303 is further configured to update multiple task weights according to the target loss.

[0158] In some embodiments, the device further includes: an acquisition module.

[0159] An acquisition module is used to acquire training texts that meet a second preset condition from multiple initial training sets to obtain a target training set when the training round is the first training round. The second preset condition is used to characterize the accuracy of the processing results of the large language model on the training texts. The multiple initial training sets correspond one-to-one to the multiple natural language processing tasks, and any initial training set includes multiple training texts corresponding to the natural language processing tasks.

[0160] Accordingly, the training module 301 is specifically used for:

[0161] Obtain multiple training texts from a target training set, and call the model to be trained to output multiple output texts based on the multiple training texts.

[0162] In some implementations, any training text carries a label, and the label includes a target output text corresponding to the training text. Accordingly, the acquisition module is specifically used to:

[0163] For any initial training set, the large language model is called to process each training text in the initial training set to obtain each predicted text corresponding to each training text.

[0164] For any training text, determine the similarity between the predicted text corresponding to the training text and the target output text corresponding to the training text.

[0165] Each training text corresponding to the target similarity is determined as a target training set, and the target similarity is a similarity less than a first similarity threshold.

[0166] In some implementations, the device further includes: a second determination module.

[0167] The second determination module is used to determine the current second parameter as the candidate second parameter corresponding to the current training cycle if it is determined that the current training cycle is over. In any training cycle, each training text in the target training set participates in one training.

[0168] Accordingly, the updating module 303 is specifically used for:

[0169] If the number of candidate second parameters reaches a preset number, it is determined that the training end condition is met; a target second parameter that meets a third preset condition among the preset number of candidate second parameters is determined, and the third preset condition is used to characterize the accuracy of the candidate second parameters; and the model to be trained corresponding to the first parameter and the target second parameter is determined to be a multi-task model.

[0170] In some implementations, the update module 303 is further specifically configured to:

[0171] For any candidate second parameter, the to-be-trained model corresponding to the candidate second parameter is verified using the test text to obtain a verification result; the verification result represents the accuracy of the processing result of the to-be-trained model on the test text.

[0172] The candidate second parameter corresponding to the maximum accuracy is determined as the target second parameter.

[0173] The large model training device provided in the embodiment of the present application and the large model training method provided in the embodiment of the present application are based on the same inventive concept and have the same beneficial effects as the methods adopted, operated or implemented therein.

[0174] Corresponding to the above-mentioned embodiment of the task processing method, the present application also provides an embodiment of a computing device. Fig.11 FIG. 1 is a schematic diagram showing a structure of a computing device according to an exemplary embodiment. The computing device may be configured in a task processing device. Fig.11 As shown, the computing device includes:

[0175] The acquisition module 401 is used to acquire text data of a target task, where the target task is any one of a plurality of natural language processing tasks.

[0176] The processing module 402 is used to call the multi-task model to process the text data to obtain output text, and the multi-task model is trained according to the multi-task model training method provided in any of the aforementioned embodiments.

[0177] The computing device provided in the embodiment of the present application and the task processing method provided in the embodiment of the present application are based on the same inventive concept and have the same beneficial effects as the methods adopted, run or implemented therein.

[0178] The implementation process of the functions and effects of each module in the above-mentioned device is specifically described in the implementation process of the corresponding steps in the above-mentioned method, which will not be repeated here.

[0179] For the device embodiments, since they basically correspond to the method embodiments, the relevant parts can refer to the partial description of the method embodiments. The device embodiments described above are merely schematic, wherein the modules described as separate components may or may not be physically separated, and the components illustrated as modules may or may not be physical modules, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the present application. A person of ordinary skill in the art may understand and implement it without creative work.

[0180] It can be understood that the division of the above modules is merely a division of logical functions. In actual implementation, the functions of the above modules can be integrated into hardware entity implementations. For example, the functions of the training module 301, the first determination module 302, the update module 303 and the processing module 402 can be integrated into the processor implementation, and the function of the acquisition module 401 can be integrated into the transceiver implementation, etc.

[0181] Based on this, some embodiments of the present application also provide an electronic device corresponding to the large model training method and task processing method provided in the aforementioned implementation manner. Fig.12 FIG. 1 is a block diagram of an electronic device used to implement an embodiment of the present application. Fig.12 As shown, the electronic device includes: a memory 501 and a processor 502, and the memory 501 stores a computer program that can be run on the processor 502. When the processor 502 executes the computer program, the method in the above embodiment is implemented. The number of the memory 501 and the processor 502 can be one or more. In a specific implementation, the electronic device may also include a communication interface 503 for communicating with external devices and performing data exchange transmission.

[0182] In specific implementation, if the memory 501, the processor 502 and the communication interface 503 are implemented independently, the memory 501, the processor 502 and the communication interface 503 can be connected to each other through a bus and communicate with each other. The bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Fig.12 Only one thick line is used in the diagram, but this does not mean that there is only one bus or only one type of bus.

[0183] Optionally, in a specific implementation, if the memory 501, the processor 502 and the communication interface 503 are integrated on a chip, the memory 501, the processor 502 and the communication interface 503 can communicate with each other through an internal interface.

[0184] An embodiment of the present application provides a computer-readable storage medium storing a computer program, which implements the method provided in the embodiment of the present application when the program is executed by a processor.

[0185] An embodiment of the present application provides a computer program product, including a computer program, which implements the method provided in the embodiment of the present application when executed by a processor.

[0186] An embodiment of the present application also provides a chip, which includes a processor for calling and executing instructions stored in the memory from the memory, so that a communication device equipped with the chip executes the method provided by the embodiment of the present application.

[0187] An embodiment of the present application also provides a chip, including: an input interface, an output interface, a processor and a memory, wherein the input interface, the output interface, the processor and the memory are connected via an internal connection path, and the processor is used to execute the code in the memory. When the code is executed, the processor is used to execute the method provided in the embodiment of the application.

[0188] It should be understood that the above processor can be a processor (Central Processing Unit, CPU), and can also be other general-purpose processors, digital signal processors (Digital Signal Processor, DSP), application-specific integrated circuits (Application Specific Integrated Circuit, ASIC), field programmable gate arrays (Field Programmable Gate Array, FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor can be a microprocessor or any conventional processor, etc. It is worth noting that the processor can be a processor that supports the Advanced RISC Machines (ARM) architecture.

[0189] Further, optionally, the above-mentioned memory may include a read-only memory and a random access memory. The memory may be a volatile memory or a non-volatile memory, or may include both volatile and non-volatile memory. Among them, the non-volatile memory may include a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. The volatile memory may include a random access memory (RAM), which is used as an external cache. By way of exemplary but not limiting description, many forms of RAM are available. For example, static random access memory (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDR SDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link dynamic random access memory (SLDRAM) and direct memory bus random access memory (DR RAM).

[0190] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function according to the present application is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium.

[0191] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "example", "specific example", or "some examples" means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present application. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner. In addition, those skilled in the art may combine and combine different embodiments or examples described in this specification and the features of different embodiments or examples, unless they are contradictory.

[0192] In addition, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Therefore, a feature defined as "first" or "second" may explicitly or implicitly include at least one of the features. In the description of this application, the meaning of "plurality" is two or more, unless otherwise clearly and specifically defined.

[0193] Any process or method described in the flow chart or otherwise described herein can be understood as a module, fragment or portion of a code representing one or more executable instructions for implementing the steps of a specific logical function or process. And the scope of the preferred embodiment of the present application includes other implementations, in which the functions may not be performed in the order shown or discussed, including in a substantially simultaneous manner or in a reverse order according to the functions involved.

[0194] The logic and / or steps described in the flowchart or otherwise described herein, for example, can be considered as an ordered list of executable instructions for implementing logical functions, which can be embodied in any computer-readable medium for use by an instruction execution system, apparatus or device (such as a computer-based system, a system including a processor or other system that can fetch instructions from an instruction execution system, apparatus or device and execute instructions), or used in combination with these instruction execution systems, apparatuses or devices.

[0195] It should be understood that the various parts of the present application can be implemented with hardware, software, firmware or a combination thereof. In the above embodiments, multiple steps or methods can be implemented with software or firmware stored in a memory and executed by a suitable instruction execution system. All or part of the steps of the above embodiment method can be completed by instructing the relevant hardware through a program, which can be stored in a computer-readable storage medium, and when the program is executed, it includes one of the steps of the method embodiment or a combination thereof.

[0196] In addition, each functional unit in each embodiment of the present application can be integrated into a processing module, or each unit can exist physically separately, or two or more units can be integrated into one module. The above-mentioned integrated module can be implemented in the form of hardware or in the form of a software functional module. If the above-mentioned integrated module is implemented in the form of a software functional module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. The storage medium can be a read-only memory, a disk or an optical disk, etc.

[0197] The above is only an exemplary embodiment of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of various changes or substitutions within the technical scope recorded in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application shall be based on the protection scope of the claims.

Claims

1. A large model training method, characterized in that: The method comprises: In any training round, the model to be trained is called to output multiple output texts based on multiple training texts, the model to be trained includes a large language model and at least one extended network, any decoding block of the large language model includes multiple first processing layers, any extended network is used to learn relevant knowledge of multiple natural language processing tasks, the number of network layers of any extended network is the same as the number of network layers of the decoding block, the initial parameters of the second processing layer in any extended network are zero, and the initial parameters of the extended layer are the same as the parameters of the corresponding first processing layer, and the first parameters of the large language model in the training round are in a locked state; determining a target loss based on target data, the target data including the plurality of output texts; The second parameter of the at least one extended network is updated according to the target loss until it is determined that the training end condition is met, thereby obtaining a multi-task model.

2. The method according to claim 1, characterized in that In the case where the training round is the first training round, before calling the model to be trained to output multiple output texts based on multiple training texts, the method further includes: Calling a preset function interface, adding at least one extended network to the large language model obtained by pre-training, to obtain the model to be trained; The update state of the first parameter is configured as a locked state, and the second parameter and a plurality of task weights are initialized, wherein the plurality of task weights correspond one-to-one to the plurality of natural language processing tasks.

3. The method according to claim 2, characterized in that The large language model includes a plurality of connected decoding blocks, and the adding at least one extended network to the pre-trained large language model includes: Dividing the plurality of decoding blocks into at least one block combination; For any block combination, at least one extended network is added at a preset position in the block combination.

4. The method according to claim 3, characterized in that The initializing the second parameter comprises: Initializing the parameters of the second processing layer in the extended network to zero; For any extended layer, determining a first processing layer in the decoding block corresponding to the extended layer, the position of the extended layer in the extended network is the same as the position of the first processing layer in the decoding block, and the extended layer is a layer in the extended network except the second processing layer; Initialize the parameters of the extension layer to the parameters of the first processing layer.

5. The method according to any one of claims 2 to 4, characterized in that: The target data also includes the multiple task weights, and determining the target loss according to the target data includes: Dividing the plurality of output texts into a plurality of text sets, wherein the plurality of text sets correspond one-to-one to the plurality of natural language processing tasks; For any natural language processing task, determine a first loss corresponding to the natural language processing task according to a text set corresponding to the natural language processing task and a task weight corresponding to the natural language processing task; The target loss is determined according to the first loss corresponding to each natural language processing task.

6. The method according to claim 5, characterized in that The determining, according to the text set corresponding to the natural language processing task and the task weight corresponding to the natural language processing task, a first loss corresponding to the natural language processing task includes: For any output text in the text set corresponding to the natural language processing task, determine multiple probabilities corresponding to the output text, the multiple probabilities correspond to multiple target characters in the output text one by one, any probability is the maximum probability in the probability distribution corresponding to the corresponding target character, the probability distribution corresponding to any target character includes the probability that the character is each preset character, the target character is a character that satisfies a first preset condition, and the first preset condition is used to constrain the length of the identifier corresponding to the character; Determine a sub-loss corresponding to the output text according to the multiple probabilities; The first loss is determined according to the sub-loss corresponding to each output text in the text set and the task weight corresponding to the natural language processing task.

7. The method according to claim 6, characterized in that Before determining a plurality of probabilities corresponding to the output text, the method further includes: For any character in the output text, determining a target identifier corresponding to the character in a preset mapping table; If it is determined that the length of the target identifier is not greater than the preset length, the character corresponding to the target identifier is determined as the target character.

8. The method according to claim 2, characterized in that: After determining the target loss according to the target data, the method further includes: The plurality of task weights are updated according to the target loss.

9. The method according to claim 2, characterized in that: In the case where the training round is the first training round, the method further includes: Acquire training texts satisfying a second preset condition from a plurality of initial training sets to obtain a target training set, wherein the plurality of initial training sets correspond one-to-one to the plurality of natural language processing tasks, and any initial training set includes a plurality of training texts corresponding to the natural language processing task, and the second preset condition is used to characterize the accuracy of the processing result of the large language model on the training text; The calling of the to-be-trained model to output a plurality of output texts based on a plurality of training texts comprises: A plurality of training texts are obtained from the target training set, and the model to be trained is called to output a plurality of output texts based on the plurality of training texts.

10. The method according to claim 9, characterized in that Any training text carries a label, and the label includes a target output text corresponding to the training text; The step of acquiring training texts satisfying the second preset condition from a plurality of initial training sets to obtain a target training set includes: For any initial training set, calling the large language model to process each training text in the initial training set to obtain each predicted text corresponding to each training text; For any training text, determining the similarity between a predicted text corresponding to the training text and a target output text corresponding to the training text; Each training text corresponding to the target similarity is determined as a target training set, and the target similarity is a similarity less than a first similarity threshold.

11. The method according to claim 9, characterized in that The method further comprises: If it is determined that the current training cycle is over, the current second parameter is determined as a candidate second parameter corresponding to the current training cycle, and in any training cycle, each training text in the target training set participates in one training; The determining that the training end condition is met to obtain the multi-task model includes: If the number of the candidate second parameters reaches a preset number, determining that the training end condition is met; Determine a target second parameter that satisfies a third preset condition among the preset number of candidate second parameters, where the third preset condition is used to characterize the accuracy of the candidate second parameter; The model to be trained corresponding to the first parameter and the target second parameter is determined as the multi-task model.

12. The method according to claim 11, characterized in that The determining of a target second parameter that satisfies a third preset condition among the preset number of candidate second parameters includes: For any candidate second parameter, use the test text to verify the to-be-trained model corresponding to the candidate second parameter to obtain a verification result, wherein the verification result represents the accuracy of the processing result of the to-be-trained model on the test text; The candidate second parameter corresponding to the maximum accuracy is determined as the target second parameter.

13. A task processing method, characterized in that: The method comprises: Acquire text data of a target task, where the target task is any one of a plurality of natural language processing tasks; A multi-task model is called to process the text data to obtain output text, wherein the multi-task model is trained according to the training method according to any one of claims 1 to 12.

14. A large model training device, characterized in that: The device comprises: A training module, used for calling a model to be trained to output multiple output texts based on multiple training texts in any training round, wherein the model to be trained includes a large language model and at least one extended network, any decoding block of the large language model includes multiple first processing layers, any extended network is used to learn relevant knowledge of multiple natural language processing tasks, the number of network layers of any extended network is the same as the number of network layers of the decoding block, the initial parameters of the second processing layer in any extended network are zero, the initial parameters of any extended layer are the same as the parameters of the corresponding first processing layer, and the first parameters of the large language model in the training round are in a locked state; A first determination module, configured to determine a target loss according to target data, wherein the target data includes the plurality of output texts; An updating module is used to update the second parameter of the at least one extended network according to the target loss until it is determined that the training end condition is met to obtain a multi-task model.

15. A computing device, characterized in that: The device comprises: An acquisition module, used to acquire text data of a target task, wherein the target task is any one of a plurality of natural language processing tasks; A processing module is used to call a multi-task model to process the text data to obtain output text, wherein the multi-task model is trained according to the training method according to any one of claims 1-12.

16. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: The processor executes the program to implement the method according to any one of claims 1 to 13.

17. A computer-readable storage medium having a computer program stored thereon, characterized in that: The program is executed by a processor to implement the method according to any one of claims 1 to 13.

18. A computer program product comprising a computer program, characterized in that The computer program is executed by a processor to implement the method according to any one of claims 1 to 13.

Citation Information

Patent Citations

  • Natural language processing method and device, model training method and device and storage medium

    CN116775807A

  • Enhanced data screening method and device based on multi-language model, equipment and medium

    CN116776900A

  • Multi-task model training method, multi-task processing method and device

    CN117830790A