Fine adjustment and reasoning method and device of pre-training model, equipment, medium and product
By locally training and integrating the compressed model of the pretrained model, combined with federated learning conditions, the problem of data leakage in fine-tuning of the pretrained model is solved, and safe and efficient parameter adjustment and resource utilization are achieved.
Patent Information
- Application Number
- CN202411335437.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-24
- Publication Date
- 2025-01-07
AI Technical Summary
In the existing pretrained model fine-tuning scheme, data transmission to the other party is required to cause data leakage.
By obtaining the compressed model sent by the pretrained model, local training of the prefix adjustment parameters, combining the pretrained model integration, and deploying the network layer for adjustment, ensuring that the parameters are saved locally, avoiding data leakage, and through federated learning conditions and joint training parameters Calculate to achieve optimal parameter adjustment.
The secure fine-tuning of the pre-trained model is realized, which protects the input data of the industry data party and avoids data leakage, while improving the resource utilization rate of the pre-trained model.
Smart Images

Figure CN119272843A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the technical field of artificial intelligence, and more specifically, to a method, device, equipment, medium and product for fine-tuning and reasoning a pre-trained model. Background Art
[0002] With the continuous development of big data and artificial intelligence technology, pre-trained large language models have achieved remarkable results in the field of natural language processing. For specific industry fields, it is also necessary to use industry-specific data to fine-tune the pre-trained large models so that they can achieve better reasoning results in that field.
[0003] In the existing fine-tuning scheme, the industry data party needs to send its own data to the pre-trained model party, and the pre-trained model party will perform fine-tuning training. Or the pre-trained model party needs to send its trained pre-trained model to the industry data party, and the industry data party will perform fine-tuning training. However, the above schemes will cause one party to obtain all the data of the other party, thereby causing its data to be leaked. Summary of the invention
[0004] The embodiments of the present disclosure at least provide a method, device, equipment, medium and product for fine-tuning and reasoning a pre-trained model.
[0005] In a first aspect, the present disclosure provides a method for fine-tuning a pre-trained model, which is applied to industry data, including:
[0006] Obtaining a compression model of the pre-trained model sent by the pre-trained model party, and locally training the prefix adjustment parameter through the compression model to obtain a first parameter value of the prefix adjustment parameter;
[0007] Integrating the first parameter value of the prefix adjustment parameter with the pre-trained model to obtain a target pre-trained model;
[0008] The prefix adjustment parameter is adjusted through the first network layer deployed in the target pre-trained model to obtain the optimal parameter value of the prefix adjustment parameter for the industry data party, wherein the first network layer includes a word segmenter, an embedding layer and a partial model parameter layer, and the remaining model parameter layers and text output layer of the pre-trained model are deployed on the pre-trained model party.
[0009] In an optional implementation, the model parameters of the word segmenter, the embedding layer and some model parameter layers in the compression model of the pre-trained model are the same as the model parameters of the corresponding network layers in the pre-trained model.
[0010] In an optional implementation, adjusting the prefix adjustment parameter through the first network layer deployed in the target pre-trained model to obtain the optimal parameter value of the prefix adjustment parameter for the industry data party includes:
[0011] Processing the input sample through the first network layer to obtain a first result;
[0012] Sending the first result to the pre-trained model party for processing, and obtaining a second result obtained by the pre-trained model party after processing the first result through a second network layer; the second network layer is a network layer in the pre-trained model deployed on the pre-trained model party;
[0013] The prefix adjustment parameter is adjusted based on the second result to obtain an optimal parameter value of the prefix adjustment parameter for the industry data party.
[0014] In an optional implementation manner, adjusting the prefix adjustment parameter based on the second result to obtain an optimal parameter value of the prefix adjustment parameter for the industry data party includes:
[0015] Obtaining a sample label of the input sample;
[0016] The function value of the target loss function is calculated according to the second result and the sample label, and the prefix adjustment parameter is reversely updated according to the function value until an optimal parameter value of the prefix adjustment parameter that meets a preset condition is obtained.
[0017] In an optional implementation manner, the processing the input sample through the first network layer to obtain the first result includes:
[0018] The input sample is processed sequentially by the word segmenter and the embedding layer to obtain an embedding result output by the embedding layer, and the embedding result is input to the prefix fine-tuning parameter layer to obtain a prefix hidden state;
[0019] The prefix hidden state and the embedding result are input into the partial model parameter layer, the hidden state is calculated, and the hidden state is determined as the first result.
[0020] In an optional implementation manner, sending the first result to the pre-trained model for processing includes:
[0021] Performing serialization and compression processing on the first result to obtain compressed data;
[0022] The compressed data is sent to the pre-trained model for processing.
[0023] In an optional implementation, adjusting the prefix adjustment parameter through the first network layer deployed in the target pre-trained model to obtain the optimal parameter value of the prefix adjustment parameter for the industry data party includes:
[0024] Determining whether the prefix adjustment parameter satisfies a federated learning condition;
[0025] When it is determined that the federated learning conditions are met, the prefix adjustment parameter is adjusted through the first network layer of the target pre-trained model deployed in multiple industry data parties to obtain the optimal parameter value of the prefix adjustment parameter for the industry data party.
[0026] In an optional implementation, the step of adjusting the prefix adjustment parameter through the first network layer of the target pre-trained model deployed in the plurality of industry data entities to obtain the optimal parameter value of the prefix adjustment parameter for the industry data entity includes:
[0027] Calculate a joint training parameter of the prefix adjustment parameter based on the amount of data of each industry data party in each round of training process and the target prefix adjustment parameter output by the round of training process;
[0028] Control each of the industry data parties to share the joint training parameters with other industry data parties, and control the industry data party to sum the received second joint training parameters to obtain a first summation result;
[0029] Summing the first summation results determined by each of the industry data parties to obtain a second summation result, and calculating a parameter value of a prefix adjustment parameter output by the round of training process based on the second summation result;
[0030] The above steps are repeatedly performed until the optimal parameter value of the prefix adjustment parameter for the industry data party is obtained.
[0031] In an optional implementation, the calculating of the joint training parameters of the prefix adjustment parameters based on the amount of data of each industry data party in each round of training process and the target prefix adjustment parameters outputted in the round of training process includes:
[0032] Calculate a target random tensor based on the target prefix adjustment parameter and the data amount;
[0033] The joint training parameters are determined based on the target random tensor.
[0034] In a second aspect, an embodiment of the present disclosure provides a method for fine-tuning a pre-trained model, which is applied to a pre-trained model, on which a second network layer of the pre-trained model is deployed, wherein the second network layer includes a second model parameter layer and a text output layer, including:
[0035] Determine the pre-trained model;
[0036] The pre-trained model is compressed to obtain a compressed model, and the compressed model is sent to the industry data party; wherein, after obtaining the compressed model, the industry data party processes it according to any one of the methods described in the first aspect above to obtain the optimal parameter value of the prefix adjustment parameter of the pre-trained model for the industry data party.
[0037] In an optional implementation manner, compressing the pre-trained model to obtain a compressed model includes:
[0038] Constructing student models;
[0039] When the parameters of the target network layer of the student model are in a frozen state, the parameters to be trained in the student model are trained through the output results of the student model and the pre-trained model on the samples, and the compression model is obtained after training; wherein the target network layer includes a word segmenter, an embedding layer and a partial model parameter layer.
[0040] In a third aspect, the present disclosure provides a method for reasoning a pre-trained model, including:
[0041] The input text is processed by a third network layer in the pre-trained model to obtain a first processing result; wherein the third network layer includes: a word segmenter, an embedding layer and at least part of a model parameter layer, and the parameter value of the prefix adjustment parameter in the pre-trained model is adjusted by the method described in any one of the first and second aspects above;
[0042] Sending the first processing result to the pre-trained model party for processing;
[0043] Obtain a text generation result fed back by the pre-trained model party; wherein the text generation result is obtained by the pre-trained model party after performing text generation processing on a second processing result, and the second processing result is obtained by the pre-trained model party after processing the first processing result.
[0044] In a fourth aspect, the present disclosure provides a fine-tuning device for a pre-trained model, which is disposed in an industry data source, and includes:
[0045] A first acquisition unit is used to acquire a compression model of the pre-trained model sent by the pre-trained model party, and locally train the prefix adjustment parameter through the compression model to obtain a first parameter value of the prefix adjustment parameter;
[0046] An integration unit, configured to integrate the first parameter value of the prefix adjustment parameter with the pre-trained model to obtain a target pre-trained model;
[0047] A parameter training unit is used to adjust the prefix adjustment parameter through the first network layer deployed in the target pre-trained model to obtain the optimal parameter value of the prefix adjustment parameter for the industry data party, wherein the first network layer includes a word segmenter, an embedding layer and a partial model parameter layer, and the remaining model parameter layers and text output layer of the pre-trained model are deployed on the pre-trained model party.
[0048] In a fifth aspect, an embodiment of the present disclosure provides a fine-tuning device for a pre-trained model, which is arranged on a pre-trained model side, on which a second network layer of the pre-trained model is deployed, wherein the second network layer includes a second model parameter layer and a text output layer, including:
[0049] A determination unit, used to determine a pre-training model;
[0050] A compression unit, used to compress the pre-trained model to obtain a compressed model;
[0051] A first sending unit is used to send the compression model to the industry data party; wherein, after obtaining the compression model, the industry data party processes it according to any one of the methods in the first aspect above to obtain the optimal parameter value of the prefix adjustment parameter of the pre-trained model for the industry data party.
[0052] In a sixth aspect, an embodiment of the present disclosure provides an inference device for a pre-trained model, comprising:
[0053] A text processing unit, configured to process an input text through a third network layer in a pre-trained model to obtain a first processing result; wherein the third network layer includes: a word segmenter, an embedding layer and at least part of a model parameter layer, and the parameter value of the prefix adjustment parameter in the pre-trained model is adjusted by the method described in any one of the first and second aspects above;
[0054] A second sending unit, used to send the first processing result to the pre-training model party for processing;
[0055] The second acquisition unit is used to obtain the text generation result fed back by the pre-trained model party; wherein the text generation result is obtained by the pre-trained model party after performing text generation processing on the second processing result, and the second processing result is obtained after the pre-trained model party processes the first processing result.
[0056] In the seventh aspect, an embodiment of the present disclosure further provides an electronic device, comprising: a processor, a memory and a bus, wherein the memory stores machine-readable instructions executable by the processor, and when the electronic device is running, the processor and the memory communicate through the bus, and when the machine-readable instructions are executed by the processor, the steps in any possible implementation of the first to third aspects above are performed.
[0057] In an eighth aspect, an embodiment of the present disclosure further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps in any possible implementation of the first to third aspects above are executed.
[0058] In a ninth aspect, an embodiment of the present disclosure further provides a computer program product, which is stored in a storage medium and is executed by at least one processor to execute the steps in any possible implementation of the first to third aspects above.
[0059] The disclosed embodiments provide a method, apparatus, device, medium and product for fine-tuning and reasoning of a pre-trained model. In the disclosed embodiments, the first network layer of the pre-trained model is deployed on the industry data party, wherein the first network layer includes a word segmenter, an embedding layer and a partial model parameter layer, and the remaining model parameter layers and text output layers of the pre-trained model are deployed on the pre-trained model party. Specifically, first, the compression model of the pre-trained model sent by the pre-trained model party can be obtained, and the prefix adjustment parameter of the pre-trained model can be locally trained through the compression model to obtain the first parameter value of the prefix adjustment parameter; then, the first parameter value of the prefix adjustment parameter is integrated with the pre-trained model to obtain the target pre-trained model; finally, the prefix adjustment parameter is adjusted through the first network layer deployed in the target pre-trained model to obtain the optimal parameter value of the prefix adjustment parameter for the industry data party.
[0060] In the above implementation, by sending the compression model of the pre-trained model and part of the model parameter layers of the pre-trained model to the industry data party, the parameters of other model parameter layers of the pre-trained model are not sent to the industry data party, so that the relevant data of the pre-trained model party is protected. For the industry data party, since the prefix adjustment parameter is stored locally, the security of the prefix adjustment parameter can be guaranteed to avoid leaking the prefix adjustment parameter to the pre-trained model party. The process of the industry data party adjusting the prefix adjustment parameter through the first network layer can realize the sending of the processed data of the prefix adjustment parameter through the part of the model parameter layer to the pre-trained model party, so that the pre-trained model party cannot infer the original data of the prefix adjustment parameter based on the received processed data, and therefore, the input data at the industry data party is protected.
[0061] In order to make the above-mentioned objectives, features and advantages of the present disclosure more obvious and easy to understand, preferred embodiments are specifically cited below and described in detail with reference to the attached drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0062] In order to more clearly illustrate the technical solutions of the embodiments of the present disclosure, the following is a brief introduction to the drawings required for use in the embodiments. The drawings herein are incorporated into the specification and constitute a part of the specification. These drawings illustrate embodiments consistent with the present disclosure and are used together with the specification to illustrate the technical solutions of the present disclosure. It should be understood that the following drawings only illustrate certain embodiments of the present disclosure and should not be regarded as limiting the scope. For ordinary technicians in this field, other relevant drawings can also be obtained based on these drawings without creative work.
[0063] Figure 1 A flowchart of a method for fine-tuning a pre-trained model provided in an embodiment of the present disclosure is shown;
[0064] Figure 2 A schematic diagram of distributed deployment of a pre-training model provided by an embodiment of the present disclosure on a pre-training model side and an industry data side is shown;
[0065] Figure 3 A schematic diagram of a compression model of a pre-training model provided by an embodiment of the present disclosure is shown;
[0066] Figure 4 A specific flow chart of distributed training of prefix adjustment parameters according to a complete model provided by an embodiment of the present disclosure is shown;
[0067] Figure 5 A flowchart of another method for fine-tuning a pre-trained model provided in an embodiment of the present disclosure is shown;
[0068] Figure 6 A flowchart of another method for fine-tuning a pre-trained model provided in an embodiment of the present disclosure is shown;
[0069] Figure 7 A flowchart of a method for reasoning a pre-training model provided in an embodiment of the present disclosure is shown;
[0070] Figure 8 A schematic diagram showing the relationship between multiple industry data entities and pre-trained model entities provided by an embodiment of the present disclosure is shown;
[0071] Fig. 9 A schematic diagram of a fine-tuning device for a pre-training model provided in an embodiment of the present disclosure is shown;
[0072] Fig.10A schematic diagram of another fine-tuning device for a pre-training model provided in an embodiment of the present disclosure is shown;
[0073] Fig.11 A schematic diagram of an inference device for another pre-training model provided in an embodiment of the present disclosure is shown. DETAILED DESCRIPTION
[0074] In order to make the purpose, technical scheme and advantages of the embodiments of the present disclosure clearer, the technical scheme in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the drawings in the embodiments of the present disclosure. Obviously, the described embodiments are only part of the embodiments of the present disclosure, rather than all of the embodiments. The components of the embodiments of the present disclosure generally described and shown in the drawings here can be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present disclosure provided in the drawings is not intended to limit the scope of the present disclosure for protection, but merely represents the selected embodiments of the present disclosure. Based on the embodiments of the present disclosure, all other embodiments obtained by those skilled in the art without making creative work belong to the scope of protection of the present disclosure.
[0075] It should be noted that similar reference numerals and letters denote similar items in the following drawings, and therefore, once an item is defined in one drawing, further definition and explanation thereof is not required in subsequent drawings.
[0076] The term "and / or" herein only describes an association relationship, indicating that three relationships may exist. For example, A and / or B may represent the following three situations: A exists alone, A and B exist at the same time, and B exists alone. In addition, the term "at least one" herein represents any combination of at least two of any one or more of a plurality of. For example, including at least one of A, B, and C may represent including any one or more elements selected from the set consisting of A, B, and C.
[0077] Research has found that with the continuous development of big data and artificial intelligence technology, pre-trained large language models have achieved remarkable results in the field of natural language processing. For specific industry fields, it is also necessary to use industry-specific data to fine-tune the pre-trained large models so that they can achieve better reasoning results in that field.
[0078] In the existing fine-tuning scheme, the industry data party needs to send its own data to the pre-trained model party, and the pre-trained model party will perform fine-tuning training. Or the pre-trained model party needs to send its trained pre-trained model to the industry data party, and the industry data party will perform fine-tuning training. However, the above schemes will cause one party to obtain all the data of the other party, thereby causing its data to be leaked.
[0079] Based on the above research, the present disclosure provides a method, device, equipment, medium and product for fine-tuning and reasoning of a pre-trained model. In an embodiment of the present disclosure, the first network layer of the pre-trained model is deployed on the industry data party, wherein the first network layer includes a word segmenter, an embedding layer and a partial model parameter layer, and the remaining model parameter layer and text output layer of the pre-trained model are deployed on the pre-trained model party. Specifically, first, the compression model of the pre-trained model sent by the pre-trained model party can be obtained, and the prefix adjustment parameter of the pre-trained model can be locally trained through the compression model to obtain the first parameter value of the prefix adjustment parameter; then, the first parameter value of the prefix adjustment parameter is integrated with the pre-trained model to obtain the target pre-trained model; finally, the prefix adjustment parameter is adjusted through the first network layer deployed in the target pre-trained model to obtain the optimal parameter value of the prefix adjustment parameter for the industry data party.
[0080] In the above implementation, by sending the compression model of the pre-trained model and part of the model parameter layers of the pre-trained model to the industry data party, the parameters of other model parameter layers of the pre-trained model are not sent to the industry data party, so that the relevant data of the pre-trained model party is protected. For the industry data party, since the prefix adjustment parameter is stored locally, the security of the prefix adjustment parameter can be guaranteed to avoid leaking the prefix adjustment parameter to the pre-trained model party. The process of the industry data party adjusting the prefix adjustment parameter through the first network layer can realize the sending of the processed data of the prefix adjustment parameter through the part of the model parameter layer to the pre-trained model party, so that the pre-trained model party cannot infer the original data of the prefix adjustment parameter based on the received processed data, and therefore, the input data at the industry data party is protected.
[0081] To facilitate understanding of this embodiment, a method for fine-tuning a pre-trained model disclosed in an embodiment of the present disclosure is first introduced in detail. The execution subject of the method for fine-tuning a pre-trained model provided in an embodiment of the present disclosure is generally an electronic device with certain computing capabilities. In some possible implementations, the method for fine-tuning a pre-trained model can be implemented by a processor calling computer-readable instructions stored in a memory.
[0082] See also Figure 1 As shown, it is a flowchart of a method for fine-tuning a pre-trained model provided by an embodiment of the present disclosure, the method comprising steps S101 to S103, the method is applied to industry data, wherein:
[0083] S101: Obtain a compression model of the pre-trained model sent by the pre-trained model party, and locally train a prefix adjustment parameter through the compression model to obtain a first parameter value of the prefix adjustment parameter.
[0084] In the disclosed embodiment, the pre-trained model includes a tokenizer, an embedding layer, and a model parameter layer. Figure 2 As shown, after completing the pre-training, the pre-trained model party will send the model's tokenizer, embedding layer, and some model parameter layers to the industry data party. Therefore, the industry data party deploys the first network layer and prefix adjustment parameter layer of the pre-trained model, where the first network layer includes the tokenizer, embedding layer and some model parameter layers. The pre-trained model party deploys the remaining model parameter layers and text output layers of the pre-trained model to receive computing requests from the industry data party.
[0085] Here, the partial model parameter layer may be the first model parameter layer, or the first two model parameter layers, or the first N model parameter layers, where N is less than the total number of model parameter layers. Alternatively, the value of N is associated with the degree of confidentiality of the parameters to the pre-trained model party, and the value of N is not specifically limited here, subject to what can be implemented.
[0086] In the technical solution disclosed in the present invention, since the pre-trained models are distributedly deployed on the pre-trained model party and the industry data party, this processing method causes the model to undergo remote data transmission from the industry data party to the pre-trained model party during forward propagation. This remote data transmission may have a large time delay, making it impossible to centrally train the prefix adjustment parameters.
[0087] Based on this, the pre-trained model party can compress the pre-trained model to obtain a compressed model, wherein the pre-trained model party can obtain a student model of the pre-trained model by distilling the pre-trained model, and then determine the student model as a compressed model; thereafter, the pre-trained model party can send the compressed model of the pre-trained model to the industry data party.
[0088] After obtaining the compression model, the industry data provider can locally train the prefix adjustment parameter of the pre-trained model through the compression model to obtain the first parameter value of the prefix adjustment parameter.
[0089] S102: Integrate the first parameter value of the prefix adjustment parameter with the pre-trained model to obtain a target pre-trained model; wherein the prefix adjustment parameter is used to indicate the type of information extracted by the large language model.
[0090] S103: Adjust the prefix adjustment parameter through the first network layer deployed in the target pre-trained model to obtain the optimal parameter value of the prefix adjustment parameter for the industry data party, wherein the first network layer includes a word segmenter, an embedding layer and a partial model parameter layer, and the remaining model parameter layers and text output layer of the pre-trained model are deployed on the pre-trained model party.
[0091] After the industry data party performs local training on the prefix adjustment parameters, the industry data party can integrate the trained prefix adjustment parameters with the complete pre-trained model to obtain the target pre-trained model, and then fine-tune the target pre-trained model to obtain the final fine-tuning training result, that is, the optimal parameter value of the prefix adjustment parameter for the industry data party.
[0092] The above steps will be described in detail below in conjunction with specific implementation methods.
[0093] In an optional embodiment, the model parameters of the word segmenter, the embedding layer and some model parameter layers in the compression model of the pre-trained model are the same as the model parameters of the corresponding network layers in the pre-trained model.
[0094] In the disclosed embodiment, the model compression process of the pre-trained model is mainly completed on the pre-trained model side. Here, the pre-trained large model can be compressed by model distillation. Model distillation can use the original model as a teacher model and train a smaller student model as a compression model. In order to facilitate subsequent fine-tuning training, the word segmenter, embedding layer and some model parameter layers of the student model are the same as the original pre-trained model, and the parameters of some model parameter layers are not adjusted during distillation training.
[0095] For example, Figure 3 The figure shows the structural diagram of the student model, and the italic parts represent the same parts as the teacher model.
[0096] for Figure 3 The student model shown in the figure, when training, for input x, the model predicts the output y' as:
[0097] y'=f 2,...,k (θ 2,...,k , f1(w1,x)).
[0098] Here, assuming that the partial model parameter layer described above is the first model parameter layer, then w1 represents the parameters in the first model parameter layer that are in a frozen state, and f1 represents the forward propagation calculation of x in the first model parameter layer combined with w1. 2,...,k represents the parameters to be trained in the 2nd to kth model parameter layers of the student model, f 2,...,kRepresents the forward propagation calculations performed in these model parameter layers. Based on the output of y', combined with the actual output y and the teacher model, θ is trained according to the common method of model distillation. Here, the specific distillation training is not introduced in detail.
[0099] After the model compression is completed, the pre-trained model party sends the student model to the industry data party, and the industry data party performs the first fine-tuning training on the prefix adjustment parameters locally.
[0100] After the student model is obtained, the prefix adjustment parameter can be locally trained using the student model to obtain a first parameter value of the prefix adjustment parameter.
[0101] In specific implementation, the input data in the sample data can be processed through the word segmenter and the embedding layer in turn to obtain the embedding result. The embedding result is input into the prefix fine-tuning parameter layer to obtain the prefix hidden state. The suffix hidden state and the embedding result are combined and input into the remaining model parameter layer of the student model to obtain the output result. The loss function is calculated based on the label of the sample data and the output result, and the prefix adjustment parameter is reversely updated based on the loss function.
[0102] After local training is completed, the training results of the prefix adjustment parameters can be loaded into Figure 1 In the distributed model architecture in . The previous training results can be used as the initial value for this time to continue the distributed prefix adjustment parameter training.
[0103] In an optional implementation, the above step S103 adjusts the prefix adjustment parameter through the first network layer deployed in the target pre-trained model to obtain the optimal parameter value of the prefix adjustment parameter for the industry data party, specifically including the following steps:
[0104] Step S11, processing the input sample through the first network layer to obtain a first result;
[0105] Step S12, sending the first result to the pre-trained model party for processing, and obtaining a second result of the pre-trained model party processing the first result through a second network layer; wherein the second network layer is a network layer in the pre-trained model deployed on the pre-trained model party;
[0106] Step S13: adjusting the prefix adjustment parameter based on the second result to obtain an optimal parameter value of the prefix adjustment parameter for the industry data party.
[0107] In the embodiment of the present disclosure, first, an input sample is obtained, and then the input sample is processed by the first network layer to obtain a first result. From the above description, it can be seen that the first network layer includes a word segmenter, an embedding layer and a part of the model parameter layer.
[0108] Based on this, the input sample is processed by the first network layer to obtain a first result, which specifically includes the following steps:
[0109] First, the input sample is processed in sequence by the word segmenter and the embedding layer to obtain an embedding result output by the embedding layer, and the embedding result is input into the prefix fine-tuning parameter layer to obtain a prefix hidden state;
[0110] Then, the prefix hidden state and the embedding result are input into the partial model parameter layer, the hidden state is calculated, and the hidden state is determined as the first result.
[0111] like Figure 4 As shown, in each round of training, the industry data side mainly includes the following processes: obtaining input samples, word segmentation and embedding processing of input samples, calculating prefix hidden states, calculating hidden states of some model parameter layers, and serialization and compression of data.
[0112] Specifically, the industry data provider obtains the input sample x (one or more records) in the training data set, and the input sample x is processed by the tokenizer and the embedding layer to obtain the output of the embedding layer, that is, the embedding result; then, the result after the tokenization and embedding process (that is, the embedding result) is used to calculate the prefix hidden state. For example, the embedding result can be input into the prefix fine-tuning parameter layer to obtain the prefix hidden state.
[0113] After that, the embedding result output by the embedding layer and the prefix hidden state are input into the partial model parameter layer to calculate the hidden state. After the hidden state is obtained, it is serialized to convert the data structure of the Tensor into a binary file. In addition, the hidden state can also be compressed, and the file size can be reduced by compression to facilitate network transmission. At this time, the binary file or compressed file is the first result described above.
[0114] After obtaining the first result, the first result can be sent to the pre-trained model party for processing, and a second result can be obtained by the pre-trained model party processing the first result through the second network layer; wherein the second network layer is a network layer in the pre-trained model deployed on the pre-trained model party.
[0115] In a specific implementation, the first result can be serialized and compressed to obtain compressed data; then, the compressed data is sent to the pre-trained model for processing.
[0116] like Figure 4As shown, the industry data party can send the serialized and compressed data to the pre-trained model party through the network, and then the pre-trained model party can perform the following processes: decompression and deserialization, calculation of model output, and serialization and compression of the model output results. Specifically, after the pre-trained model party decompresses and deserializes the received data, it inputs it into the remaining model parameter layers of the pre-trained model for calculation, and continues to perform subsequent calculations until the model output y' (that is, the second result) is obtained. At this time, you can choose to retain the data structure of the Tensor tensor without converting it into the final text output. Then, the pre-trained model serializes and compresses the second result y', and then sends it to the industry data party for processing, so that the industry data party adjusts the prefix adjustment parameter based on the second result to obtain the optimal parameter value of the prefix adjustment parameter for the industry data party.
[0117] In an optional implementation, the above step adjusts the prefix adjustment parameter based on the second result to obtain the optimal parameter value of the prefix adjustment parameter for the industry data party, specifically comprising the following steps:
[0118] First, obtain the sample label of the input sample;
[0119] Secondly, the function value of the target loss function is calculated according to the second result and the sample label, and the prefix adjustment parameter is reversely updated according to the function value until the optimal parameter value of the prefix adjustment parameter that meets the preset conditions is obtained.
[0120] In the disclosed embodiment, after receiving the second result sent by the pre-trained model party, the industry data party needs to decompress and deserialize it to obtain the model output y'. Then calculate the loss value based on the label, for example, it can be compared with the original label y of the input sample, and then calculate the function value of the target loss function based on the model output and the original label. The prefix adjustment parameter is reversely updated according to the function value of the target loss function, thereby completing a round of training.
[0121] Here, the stop condition of the training can be set in advance, for example, the stop condition can be set according to the training round and the training accuracy. After multiple rounds of training, if the stop condition described above is met, all training is terminated. At this time, the prefix adjustment parameter obtained from the last round of training is the final training result.
[0122] In an optional implementation, adjusting the prefix adjustment parameter through the first network layer deployed in the target pre-trained model to obtain the optimal parameter value of the prefix adjustment parameter for the industry data party includes:
[0123] Determining whether the prefix adjustment parameter satisfies a federated learning condition;
[0124] When it is determined that the federated learning conditions are met, the prefix adjustment parameter is adjusted through the first network layer of the target pre-trained model deployed in multiple industry data parties to obtain the optimal parameter value of the prefix adjustment parameter for the industry data party.
[0125] In the disclosed embodiment, first, it is possible to determine whether the prefix adjustment parameters meet the federated learning conditions. For example, it is possible to determine whether the amount of local data of the current industry data party can meet the training requirements; if it is determined that the training requirements are met, it is determined that the federated learning conditions are not met; if it is determined that the training requirements are not met, it is determined that the federated learning conditions are met. For another example, the training mode pre-set by the current industry data party for the pre-trained model can be obtained; if the training mode is obtained as a federated training mode, it is determined that the federated learning conditions are met; otherwise, it is determined that the federated learning conditions are not met.
[0126] From the above description, it can be seen that the amount of local data of a single industry data party may not be enough. In this case, multiple industry data parties in the same industry can be aggregated to adjust the prefix adjustment parameters; or, when the training mode is determined to be a federated training mode, multiple industry data parties in the same industry can adjust the prefix adjustment parameters. Figure 4 In the process of reverse updating the prefix adjustment parameters, the parameters can be updated by using federated learning.
[0127] Based on this, the prefix adjustment parameter is adjusted through the first network layer of the target pre-trained model deployed in the plurality of the industry data parties to obtain the optimal parameter value of the prefix adjustment parameter for the industry data party, specifically including:
[0128] Step S21, calculating a joint training parameter of the prefix adjustment parameter based on the amount of data of each industry data party in each round of training process and the target prefix adjustment parameter outputted in the round of training process;
[0129] Step S22, controlling each of the industry data parties to share the joint training parameters with other industry data parties, and controlling the industry data party to sum the received second joint training parameters to obtain a first summation result;
[0130] Step S23, summing the first summation results determined by each of the industry data parties to obtain a second summation result, and calculating the parameter value of the prefix adjustment parameter output by the training process in this round based on the second summation result;
[0131] The above steps are repeatedly performed until the optimal parameter value of the prefix adjustment parameter for the industry data party is obtained.
[0132] Here, it is assumed that there are m industry data parties as participants, and the participants can access each other. The amount of data that each participant i participates in training in each round is n i , the prefix adjustment parameter obtained by each participant i after each round of training is wp i (ie, the target prefix adjustment parameter.) Next, the joint training parameters of the prefix adjustment parameter may be calculated.
[0133] In a possible implementation manner, based on the amount of data of each industry data party in each round of training process and the target prefix adjustment parameter output by the round of training process, the joint training parameter of the prefix adjustment parameter is calculated, including:
[0134] Calculate a target random tensor based on the target prefix adjustment parameter and the data amount;
[0135] Determining the joint training parameters based on the target random tensor specifically includes the following process:
[0136] First, each participant i generates i A random tensor of the same dimension δ i , and calculate wp i With a random tensor δ i The sum and difference are: (wp i +δ i ) and (wp i -δ i ); Then, calculate the data volume n i The product of half of the sum and the difference above is and Thus, the joint training parameters of the prefix adjustment parameters are obtained.
[0137] Next, participant i can share the joint training parameters with other participants. For example, participant i can Each participant sums the joint training parameters received from other parties to obtain the second sum result. i Sent to the designated aggregator h for this round. Aggregator h sums up all the second summation results received and then calculates Where n = ∑n i Finally, wp is sent to each participant. Each participant uses wp to make the final parameter update result of this round.
[0138] From the above description, it can be seen that the technical solution disclosed in the present invention sends the compressed model after distillation of the pre-trained model party and part of the model parameter layer data of the pre-trained model party to the industry data party, and the parameters of other model parameter layers of the pre-trained model party are not sent to the industry data party, thereby being protected.
[0139] For the industry data party, its prefix adjustment parameters have always been saved locally and have not been leaked to the pre-trained model party; the data sent to the pre-trained model party during the training process is the hidden state value of the partial parameter layer, which is calculated by the input data through the prefix fine-tuning parameter layer and the partial parameter layer. Since the pre-trained model party does not know the true value of the prefix fine-tuning parameter of the industry data party, it is impossible to infer the original input data at the industry data party based solely on the received data and the parameter values of the partial parameter layer. Therefore, the input data at the industry data party is protected. In addition, when training the model, since the label data y is not sent to the pre-trained model party, it is also protected.
[0140] On the basis of protecting data privacy, the original pre-trained model parameters in the disclosed technical solution are not changed, and the fine-tuning training adjusts the local prefix fine-tuning parameters of the industry data party. Therefore, when adopting this solution, multiple industry data parties can share a pre-trained model at the same time, thereby improving the resource utilization of the pre-trained model party.
[0141] See also Figure 5 As shown, it is a flowchart of another method for fine-tuning a pre-trained model provided in an embodiment of the present disclosure, the method includes steps S501-S502, the method is applied to a pre-trained model, wherein: a second network layer of the pre-trained model is deployed on the pre-trained model, wherein the second network layer includes a second model parameter layer and a text output layer, and the method includes:
[0142] S501: Determine a pre-training model;
[0143] S502: compress the pre-trained model to obtain a compressed model, and send the compressed model to the industry data party; wherein, after obtaining the compressed model, the industry data party processes it according to any of the methods in the above embodiments to obtain the optimal parameter value of the prefix adjustment parameter of the pre-trained model for the industry data party.
[0144] like Figure 6 As shown, after sending the compression model to the industry data party, the industry data party uses the compression model to locally train the prefix adjustment parameters, loads the trained prefix adjustment parameters into the complete model, and trains the prefix adjustment parameters in a distributed manner based on the complete model.
[0145] In the above implementation, by sending the compression model of the pre-trained model and part of the model parameter layers of the pre-trained model to the industry data party, the parameters of other model parameter layers of the pre-trained model are not sent to the industry data party, so that the relevant data of the pre-trained model party is protected. For the industry data party, since the prefix adjustment parameter is stored locally, the security of the prefix adjustment parameter can be guaranteed to avoid leaking the prefix adjustment parameter to the pre-trained model party. The process of the industry data party adjusting the prefix adjustment parameter through the first network layer can realize the sending of the processed data of the prefix adjustment parameter through the part of the model parameter layer to the pre-trained model party, so that the pre-trained model party cannot infer the original data of the prefix adjustment parameter based on the received processed data, and therefore, the input data at the industry data party is protected.
[0146] In an optional implementation, compressing the pre-trained model to obtain a compressed model includes:
[0147] Constructing student models;
[0148] When the parameters of the target network layer of the student model are in a frozen state, the parameters to be trained in the student model are trained through the output results of the student model and the pre-trained model on the samples, and the compression model is obtained after training; wherein the target network layer includes a word segmenter, an embedding layer and a partial model parameter layer.
[0149] In the disclosed embodiment, the model compression process of the pre-trained model is mainly completed on the pre-trained model side. Here, the pre-trained large model can be compressed by model distillation. Model distillation can use the original model as a teacher model and train a smaller student model as a compression model. In order to facilitate subsequent fine-tuning training, the word segmenter, embedding layer and some model parameter layers of the student model are the same as the original pre-trained model, and the parameters of some model parameter layers are not adjusted during distillation training.
[0150] For example, Figure 3 The figure shows the structural diagram of the student model, and the italic parts represent the same parts as the teacher model.
[0151] for Figure 3 The student model shown in the figure, when training, for input x, the model predicts the output y' as:
[0152] y'=f 2,...,k (θ 2,...,k , f1(w1,x)).
[0153] Here, assuming that the partial model parameter layer described above is the first model parameter layer, then w1 represents the parameters in the first model parameter layer that are in a frozen state, and f1 represents the forward propagation calculation of x in the first model parameter layer combined with w1. 2,...,k represents the parameters to be trained in the 2nd to kth model parameter layers of the student model, f 2,...,k Represents the forward propagation calculations performed in these model parameter layers. Based on the output of y', combined with the actual output y and the teacher model, θ is trained according to the common method of model distillation. Here, the specific distillation training is not introduced in detail.
[0154] After the model compression is completed, the pre-trained model party sends the student model to the industry data party, and the industry data party performs the first fine-tuning training on the prefix adjustment parameters locally.
[0155] See also Figure 7 As shown, it is a flowchart of a method for reasoning a pre-trained model provided in an embodiment of the present disclosure, the method includes steps S701 to S703, including:
[0156] S701: Processing the input text through the third network layer in the pre-trained model to obtain a first processing result; wherein the third network layer includes: a word segmenter, an embedding layer and at least part of the model parameter layer, and the parameter value of the prefix adjustment parameter in the pre-trained model is adjusted in the manner described in the above embodiment;
[0157] S702: Sending the first processing result to the pre-training model party for processing;
[0158] S703: Obtain the text generation result fed back by the pre-trained model party; wherein the text generation result is obtained by the pre-trained model party after performing text generation processing on the second processing result, and the second processing result is obtained by the pre-trained model party after processing the first processing result.
[0159] In the embodiment of the present disclosure, after the prefix adjustment parameters are trained in the manner described above, model inference can be performed using the pre-trained model. Figure 4 The following are basically the same, including:
[0160] The industry data party inputs the input text into the word segmenter, the embedding layer, and at least part of the model parameter layer, performs word segmentation and embedding processing in sequence, obtains the embedding result, and inputs the embedding result into the prefix fine-tuning parameter layer to obtain the prefix hidden state. The prefix hidden state and the embedding result output by the embedding layer are input into part of the model parameter layer to calculate the hidden state. For example, if part of the model parameters is the first model parameter layer, the first layer hidden state can be calculated by combining the prefix hidden state and the embedding result. The first layer hidden state is serialized and compressed and then sent to the pre-trained model party.
[0161] The pre-trained model party performs forward calculations starting from the remaining model parameter layers (eg, the second model parameter layer) until the model output result, i.e., the text result, is calculated, and the generated text result is sent to the industry data party.
[0162] During model inference, the pre-trained model party can use the same pre-trained model to serve multiple industry data parties at the same time. Figure 8 As shown in the figure, since the unique prefix adjustment parameters for each industry data entity are stored locally, and all model parameters and text output layers on the pre-trained model side are not adjusted separately for a certain industry data entity, it can be used Figure 7 The solution to implement pre-trained models is to use the same pre-trained model to serve multiple industry data providers at the same time.
[0163] Those skilled in the art will appreciate that, in the above method of specific implementation, the order in which the steps are written does not imply a strict execution order and does not constitute any limitation on the implementation process. The specific execution order of the steps should be determined by their functions and possible internal logic.
[0164] Based on the same inventive concept, the presently disclosed embodiment also provides a fine-tuning device for a pre-trained model corresponding to the fine-tuning method for a pre-trained model. Since the principle of solving the problem by the device in the presently disclosed embodiment is similar to the fine-tuning method for a pre-trained model in the presently disclosed embodiment, the implementation of the device can refer to the implementation of the method, and the repeated parts will not be repeated.
[0165] Reference Fig. 9 , which is a schematic diagram of a fine-tuning device for a pre-training model provided by an embodiment of the present disclosure, wherein the device is arranged in an industry data party, and the device comprises: a first acquisition unit 91, an integration unit 92, and a parameter training unit 93; wherein,
[0166] A first acquisition unit 91 is used to acquire a compression model of the pre-trained model sent by the pre-trained model party, and locally train the prefix adjustment parameter through the compression model to obtain a first parameter value of the prefix adjustment parameter;
[0167] An integration unit 92, configured to integrate the first parameter value of the prefix adjustment parameter with the pre-trained model to obtain a target pre-trained model;
[0168] A parameter training unit 93 is used to adjust the prefix adjustment parameter through the first network layer deployed in the target pre-trained model to obtain the optimal parameter value of the prefix adjustment parameter for the industry data party, wherein the first network layer includes a word segmenter, an embedding layer and a partial model parameter layer, and the remaining model parameter layers and text output layer of the pre-trained model are deployed on the pre-trained model party.
[0169] In a possible implementation, model parameters of a word segmenter, an embedding layer and some model parameter layers in the compression model of the pre-trained model are the same as model parameters of corresponding network layers in the pre-trained model.
[0170] In a possible implementation manner, the parameter training unit 93 is further configured to:
[0171] Processing the input sample through the first network layer to obtain a first result;
[0172] Sending the first result to the pre-trained model party for processing, and obtaining a second result obtained by the pre-trained model party after processing the first result through a second network layer; wherein the second network layer is a network layer in the pre-trained model deployed on the pre-trained model party;
[0173] The prefix adjustment parameter is adjusted based on the second result to obtain an optimal parameter value of the prefix adjustment parameter for the industry data party.
[0174] In a possible implementation manner, the parameter training unit 93 is further configured to:
[0175] Obtaining a sample label of the input sample;
[0176] The function value of the target loss function is calculated according to the second result and the sample label, and the prefix adjustment parameter is reversely updated according to the function value until an optimal parameter value of the prefix adjustment parameter that meets a preset condition is obtained.
[0177] In a possible implementation manner, the parameter training unit 93 is further configured to:
[0178] The input sample is processed sequentially by the word segmenter and the embedding layer to obtain an embedding result output by the embedding layer, and the embedding result is input to the prefix fine-tuning parameter layer to obtain a prefix hidden state;
[0179] The prefix hidden state and the embedding result are input into the partial model parameter layer, the hidden state is calculated, and the hidden state is determined as the first result.
[0180] In a possible implementation manner, the parameter training unit 93 is further configured to:
[0181] Performing serialization and compression processing on the first result to obtain compressed data;
[0182] The compressed data is sent to the pre-trained model for processing.
[0183] In a possible implementation manner, the parameter training unit 93 is further configured to:
[0184] Determining whether the prefix adjustment parameter satisfies a federated learning condition;
[0185] When it is determined that the federated learning conditions are met, the prefix adjustment parameter is adjusted through the first network layer of the target pre-trained model deployed in multiple industry data parties to obtain the optimal parameter value of the prefix adjustment parameter for the industry data party.
[0186] In a possible implementation manner, the parameter training unit 93 is further configured to:
[0187] Calculate a joint training parameter of the prefix adjustment parameter based on the amount of data of each industry data party in each round of training process and the target prefix adjustment parameter output by the round of training process;
[0188] Control each of the industry data parties to share the joint training parameters with other industry data parties, and control the industry data party to sum the received second joint training parameters to obtain a first summation result;
[0189] Summing the first summation results determined by each of the industry data parties to obtain a second summation result, and calculating a parameter value of a prefix adjustment parameter output by the round of training process based on the second summation result;
[0190] The above steps are repeatedly performed until the optimal parameter value of the prefix adjustment parameter for the industry data party is obtained.
[0191] In a possible implementation manner, the parameter training unit 93 is further configured to:
[0192] Calculate a target random tensor based on the target prefix adjustment parameter and the data amount;
[0193] The joint training parameters are determined based on the target random tensor.
[0194] Reference Fig.10As shown, it is a schematic diagram of another fine-tuning device of a pre-trained model provided in an embodiment of the present disclosure, wherein the device is arranged on a pre-trained model side, and a second network layer of the pre-trained model is deployed on the pre-trained model side, wherein the second network layer includes a second model parameter layer and a text output layer, and the device includes: a determination unit 101, a compression unit 102, and a first sending unit 103; wherein,
[0195] A determination unit 101, used to determine a pre-training model;
[0196] A compression unit 102, used to compress the pre-trained model to obtain a compressed model;
[0197] The first sending unit 103 is used to send the compression model to the industry data party; wherein, after obtaining the compression model, the industry data party processes it according to any one of the methods in the embodiments to obtain the optimal parameter value of the prefix adjustment parameter of the pre-trained model for the industry data party.
[0198] In a possible implementation manner, the compression unit 102 is specifically configured to:
[0199] Constructing student models;
[0200] When the parameters of the target network layer of the student model are in a frozen state, the parameters to be trained in the student model are trained through the output results of the student model and the pre-trained model on the samples, and the compression model is obtained after training; wherein the target network layer includes a word segmenter, an embedding layer and a partial model parameter layer.
[0201] Reference Fig.11 As shown, it is a schematic diagram of another inference device of a pre-training model provided in an embodiment of the present disclosure, wherein the device comprises: a text processing unit 111, a second sending unit 112, and a second acquiring unit 113; wherein,
[0202] The text processing unit 111 is used to process the input text through the third network layer in the pre-trained model to obtain a first processing result; wherein the third network layer includes: a word segmenter, an embedding layer and at least part of the model parameter layer, and the parameter value of the prefix adjustment parameter in the pre-trained model is adjusted by the method described in any one of the above embodiments;
[0203] A second sending unit 112 is used to send the first processing result to the pre-training model party for processing;
[0204] The second acquisition unit 113 is used to obtain the text generation result fed back by the pre-trained model party; wherein the text generation result is obtained by the pre-trained model party after performing text generation processing on the second processing result, and the second processing result is obtained after the pre-trained model party processes the first processing result.
[0205] For descriptions of the processing flow of each module in the device and the interaction flow between each module, reference may be made to the relevant descriptions in the above method embodiment, which will not be described in detail here.
[0206] The present disclosure also provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the steps of the method for fine-tuning the pre-trained model or the method for reasoning the pre-trained model described in the above method embodiment are executed. The storage medium may be a volatile or non-volatile computer-readable storage medium.
[0207] The embodiments of the present disclosure also provide a computer program product, which carries a program code. The instructions included in the program code can be used to execute the steps of the fine-tuning method of the pre-trained model or the reasoning method of the pre-trained model described in the above method embodiments. For details, please refer to the above method embodiments, which will not be repeated here.
[0208] The computer program product may be implemented in hardware, software or a combination thereof. In one optional embodiment, the computer program product is implemented as a computer storage medium. In another optional embodiment, the computer program product is implemented as a software product, such as a software development kit (SDK).
[0209] Those skilled in the art can clearly understand that, for the convenience and simplicity of description, the specific working process of the system and device described above can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here. In the several embodiments provided in the present disclosure, it should be understood that the disclosed system, device and method can be implemented in other ways. The device embodiments described above are merely 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 communication interfaces, and the indirect coupling or communication connection of the device or unit can be electrical, mechanical or other forms.
[0210] 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.
[0211] In addition, each functional unit in each embodiment of the present disclosure 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.
[0212] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a non-volatile computer-readable storage medium that is executable by a processor. Based on this understanding, the technical solution of the present disclosure, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present disclosure. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0213] Finally, it should be noted that the above-described embodiments are only specific implementation methods of the present disclosure, which are used to illustrate the technical solutions of the present disclosure, rather than to limit them. The protection scope of the present disclosure is not limited thereto. Although the present disclosure is described in detail with reference to the above-described embodiments, ordinary technicians in the field should understand that any technician familiar with the technical field can still modify the technical solutions recorded in the above-described embodiments within the technical scope disclosed in the present disclosure, or can easily think of changes, or make equivalent replacements for some of the technical features therein; and these modifications, changes or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present disclosure, and should be included in the protection scope of the present disclosure. Therefore, the protection scope of the present disclosure should be based on the protection scope of the claims.
Claims
1. A method for fine-tuning a pre-trained model, characterized in that: Applied to industry data, including: Obtaining a compression model of the pre-trained model sent by the pre-trained model party, and locally training the prefix adjustment parameter through the compression model to obtain a first parameter value of the prefix adjustment parameter; Integrating the first parameter value of the prefix adjustment parameter with the pre-trained model to obtain a target pre-trained model; The prefix adjustment parameter is adjusted through the first network layer deployed in the target pre-trained model to obtain the optimal parameter value of the prefix adjustment parameter for the industry data party, wherein the first network layer includes a word segmenter, an embedding layer and a partial model parameter layer, and the remaining model parameter layers and text output layer of the pre-trained model are deployed on the pre-trained model party.
2. The method according to claim 1, characterized in that The model parameters of the word segmenter, the embedding layer and some model parameter layers in the compression model of the pre-trained model are the same as the model parameters of the corresponding network layers in the pre-trained model.
3. The method according to claim 1, characterized in that The step of adjusting the prefix adjustment parameter through the first network layer deployed in the target pre-trained model to obtain an optimal parameter value of the prefix adjustment parameter for the industry data party includes: Processing the input sample through the first network layer to obtain a first result; Sending the first result to the pre-trained model party for processing, and obtaining a second result obtained by the pre-trained model party after processing the first result through a second network layer; the second network layer is a network layer in the pre-trained model deployed on the pre-trained model party; The prefix adjustment parameter is adjusted based on the second result to obtain an optimal parameter value of the prefix adjustment parameter for the industry data party.
4. The method according to claim 3, characterized in that The adjusting the prefix adjustment parameter based on the second result to obtain an optimal parameter value of the prefix adjustment parameter for the industry data party includes: Obtaining a sample label of the input sample; The function value of the target loss function is calculated according to the second result and the sample label, and the prefix adjustment parameter is reversely updated according to the function value until an optimal parameter value of the prefix adjustment parameter that meets a preset condition is obtained.
5. The method according to claim 3, characterized in that: The step of processing the input sample through the first network layer to obtain a first result includes: The input sample is processed sequentially by the word segmenter and the embedding layer to obtain an embedding result output by the embedding layer, and the embedding result is input to the prefix fine-tuning parameter layer to obtain a prefix hidden state; The prefix hidden state and the embedding result are input into the partial model parameter layer, the hidden state is calculated, and the hidden state is determined as the first result.
6. The method according to claim 3, characterized in that The sending the first result to the pre-trained model for processing includes: Performing serialization and compression processing on the first result to obtain compressed data; The compressed data is sent to the pre-trained model for processing.
7. The method according to claim 1, characterized in that The step of adjusting the prefix adjustment parameter through the first network layer deployed in the target pre-trained model to obtain an optimal parameter value of the prefix adjustment parameter for the industry data party includes: Determining whether the prefix adjustment parameter satisfies a federated learning condition; When it is determined that the federated learning conditions are met, the prefix adjustment parameter is adjusted through the first network layer of the target pre-trained model deployed in multiple industry data parties to obtain the optimal parameter value of the prefix adjustment parameter for the industry data party.
8. The method according to claim 7, characterized in that The step of adjusting the prefix adjustment parameter through the first network layer of the target pre-trained model deployed in the plurality of industry data entities to obtain an optimal parameter value of the prefix adjustment parameter for the industry data entity includes: Calculate a joint training parameter of the prefix adjustment parameter based on the amount of data of each industry data party in each round of training process and the target prefix adjustment parameter output by the round of training process; Control each of the industry data parties to share the joint training parameters with other industry data parties, and control the industry data party to sum the received second joint training parameters to obtain a first summation result; Summing the first summation results determined by each of the industry data parties to obtain a second summation result, and calculating a parameter value of a prefix adjustment parameter output by the round of training process based on the second summation result; The above steps are repeatedly performed until the optimal parameter value of the prefix adjustment parameter for the industry data party is obtained.
9. The method according to claim 8, characterized in that The calculating of the joint training parameters of the prefix adjustment parameters based on the amount of data of each industry data party in each round of training process and the target prefix adjustment parameters outputted in the round of training process includes: Calculate a target random tensor based on the target prefix adjustment parameter and the data amount; The joint training parameters are determined based on the target random tensor.
10. A method for fine-tuning a pre-trained model, characterized in that: Applied to a pre-trained model, on which a second network layer of the pre-trained model is deployed, wherein the second network layer includes a second model parameter layer and a text output layer, including: Determine the pre-trained model; The pre-trained model is compressed to obtain a compressed model, and the compressed model is sent to the industry data party; wherein, after obtaining the compressed model, the industry data party processes it according to the method described in any one of claims 1 to 9 above to obtain the optimal parameter value of the prefix adjustment parameter of the pre-trained model for the industry data party.
11. The method according to claim 10, characterized in that The step of compressing the pre-trained model to obtain a compressed model includes: Constructing student models; When the parameters of the target network layer of the student model are in a frozen state, the parameters to be trained in the student model are trained through the output results of the student model and the pre-trained model on the samples, and the compression model is obtained after training; wherein the target network layer includes a word segmenter, an embedding layer and a partial model parameter layer.
12. A method for inference of a pre-trained model, characterized in that: include: The input text is processed by a third network layer in the pre-trained model to obtain a first processing result; wherein the third network layer includes: a word segmenter, an embedding layer and at least part of a model parameter layer, and the parameter value of the prefix adjustment parameter in the pre-trained model is adjusted by the method described in any one of claims 1 to 11 above; Sending the first processing result to the pre-trained model party for processing; Obtain a text generation result fed back by the pre-trained model party; wherein the text generation result is obtained by the pre-trained model party after performing text generation processing on a second processing result, and the second processing result is obtained by the pre-trained model party after processing the first processing result.
13. A fine-tuning device for a pre-trained model, characterized in that: Set up on the industry data side, including: A first acquisition unit is used to acquire a compression model of the pre-trained model sent by the pre-trained model party, and locally train the prefix adjustment parameter through the compression model to obtain a first parameter value of the prefix adjustment parameter; An integration unit, configured to integrate the first parameter value of the prefix adjustment parameter with the pre-trained model to obtain a target pre-trained model; A parameter training unit is used to adjust the prefix adjustment parameter through the first network layer deployed in the target pre-trained model to obtain the optimal parameter value of the prefix adjustment parameter for the industry data party, wherein the first network layer includes a word segmenter, an embedding layer and a partial model parameter layer, and the remaining model parameter layers and text output layer of the pre-trained model are deployed on the pre-trained model party.
14. A fine-tuning device for a pre-trained model, characterized in that: The method is set on a pre-trained model side, on which a second network layer of the pre-trained model is deployed, wherein the second network layer includes a second model parameter layer and a text output layer, including: A determination unit, used to determine a pre-training model; A compression unit, used to compress the pre-trained model to obtain a compressed model; A first sending unit is used to send the compression model to the industry data party; wherein, after obtaining the compression model, the industry data party processes it according to the method described in any one of claims 1 to 9 above to obtain the optimal parameter value of the prefix adjustment parameter of the pre-trained model for the industry data party.
15. A pre-trained model reasoning device, characterized in that: include: A text processing unit, configured to process an input text through a third network layer in a pre-trained model to obtain a first processing result; wherein the third network layer includes: a word segmenter, an embedding layer and at least part of a model parameter layer, and the parameter value of the prefix adjustment parameter in the pre-trained model is adjusted by the method described in any one of claims 1 to 11 above; A second sending unit, used to send the first processing result to the pre-training model party for processing; The second acquisition unit is used to obtain the text generation result fed back by the pre-trained model party; wherein the text generation result is obtained by the pre-trained model party after performing text generation processing on the second processing result, and the second processing result is obtained after the pre-trained model party processes the first processing result.
16. An electronic device, characterized in that: include: A processor, a memory and a bus, wherein the memory stores machine-readable instructions executable by the processor, and when the electronic device is running, the processor and the memory communicate via the bus, and when the machine-readable instructions are executed by the processor, the steps of the fine-tuning method of the pre-trained model as described in any one of claims 1 to 9 are executed; or, the steps of the fine-tuning method of the pre-trained model as described in claim 10 or 11 are executed, or the steps of the reasoning method of the pre-trained model as described in claim 12 are executed.
17. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, which, when executed by a processor, executes the steps of the fine-tuning method of the pre-trained model as described in any one of claims 1 to 9; or, executes the steps of the fine-tuning method of the pre-trained model as described in claim 10 or 11, or executes the steps of the inference method of the pre-trained model as described in claim 12.
18. A computer program product, characterized in that The computer program product is stored in a storage medium, and the program product is executed by at least one processor to implement the steps of the fine-tuning method of the pre-trained model as described in any one of claims 1 to 9; Alternatively, execute the steps of the fine-tuning method of the pre-trained model as described in claim 10 or 11, or execute the steps of the reasoning method of the pre-trained model as described in claim 12.