Model processing method, device, computer equipment, storage medium and program product
By dividing the deep learning model into layer groups and using cross-block distillation technology, it solves the problems of training failure and low efficiency of traditional model distillation methods in resource-constrained environments, and achieves efficient model training and resource optimization.
Patent Information
- Application Number
- CN202410996728.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-24
- Publication Date
- 2024-10-15
- Estimated Expiration
- 2044-07-24
AI Technical Summary
The traditional model distillation method can easily lead to model training failure in resource-constrained environments, and the training efficiency is low, requiring frequent repeated model loading and adjustment.
Divide the pre-trained deep learning model and original data processing model into multiple layer groups, reduce memory usage and improve training efficiency through hierarchical training and cross-layer processing, and use cross-block distillation to fine-tune the intermediate data processing model.
It achieves efficient model training in resource-constrained environments, reduces memory consumption and repeated loading, improves model training processing efficiency, and avoids performance degradation caused by hierarchical training.
Smart Images

Figure CN118536557B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of artificial intelligence technology, and in particular to a model processing method, apparatus, computer equipment, computer-readable storage medium, and computer program product. Background Art
[0002] With the development of artificial intelligence technology and the gradual promotion and application of various deep learning models, it is necessary to train models that meet the requirements according to the needs of different actual scenarios. However, large deep learning models usually have many layers and many parameters in each layer. A large amount of memory resources are consumed during the training process, resulting in excessive resource requirements.
[0003] Traditionally, in order to reduce resource consumption during the training of various models, model distillation technology has been used to transfer the knowledge of large models to small models. A large teacher model is used to supervise the training of a small student model, so that the student network can maintain a small model size while approaching the performance of the teacher network. The trained small student model is then used for subsequent data processing.
[0004] However, under the traditional model distillation method, when migrating the knowledge of a large teacher model to a small student model, both the large teacher model and the small student model need to be loaded into the memory. Although the large teacher model does not need to be trained directly, a large amount of memory resources are still required for model loading. In a resource-constrained environment (such as edge devices), distillation failure is prone to occur, resulting in model training failure. It is necessary to reselect the container or device to repeat the model loading and training. Therefore, there is still the problem of low model training processing efficiency. Summary of the invention
[0005] Based on this, it is necessary to provide a model processing method, device, computer equipment, computer-readable storage medium and computer program product that can improve the efficiency of model training processing in response to the above technical problems.
[0006] In a first aspect, the present application provides a model processing method, comprising:
[0007] Dividing the pre-trained deep learning model and the original data processing model into a plurality of layer groups respectively; wherein each layer group in the pre-trained deep learning model corresponds to each other in the original data processing model;
[0008] Obtain a first training data set, and for each layer group of the original data processing model, perform hierarchical training on the targeted layer group according to the first training data set, the pre-trained deep learning model, and the target layer group corresponding to the targeted layer group, until the hierarchical training of all layer groups of the original data processing model is completed, thereby obtaining an intermediate data processing model;
[0009] The pre-trained deep learning model and the intermediate data processing model are cross-layered to obtain a plurality of cross-layer groups; the cross-layer groups include at least two first adjacent layer groups selected from the pre-trained deep learning model, and at least two second adjacent layer groups selected from the intermediate data processing model corresponding to the at least two first adjacent layer groups;
[0010] Obtain a second training data set, and for each cross-layer group in the multiple cross-layer groups, perform distillation training on the at least two second adjacent layer groups in the cross-layer group according to the second training data set and the at least two first adjacent layer groups in the cross-layer group, until each of the cross-layer groups meets the model training end condition, thereby obtaining a trained target data processing model.
[0011] In a second aspect, the present application also provides a model processing device, comprising:
[0012] A layer group division module, used to divide the pre-trained deep learning model and the original data processing model into a plurality of layer groups respectively; each layer group in the pre-trained deep learning model and the original data processing model corresponds one to one;
[0013] A hierarchical training module is used to obtain a first training data set, and for each layer group of the original data processing model, perform hierarchical training on the targeted layer group according to the first training data set, the pre-trained deep learning model and the target layer group corresponding to the targeted layer group, until the hierarchical training of all layer groups of the original data processing model is completed to obtain an intermediate data processing model;
[0014] A cross-layering module, used to perform cross-layering processing on the pre-trained deep learning model and the intermediate data processing model to obtain a plurality of cross-layer groups; the cross-layer groups include at least two first adjacent layer groups selected from the pre-trained deep learning model, and at least two second adjacent layer groups selected from the intermediate data processing model corresponding to the at least two first adjacent layer groups;
[0015] A distillation training module is used to obtain a second training data set, and for each cross-layer group in the multiple cross-layer groups, perform distillation training on the at least two second adjacent layer groups in the cross-layer group according to the second training data set and the at least two first adjacent layer groups in the cross-layer group, until each of the cross-layer groups meets the model training end condition, thereby obtaining a trained target data processing model.
[0016] In a third aspect, the present application further provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the following steps are implemented:
[0017] Dividing the pre-trained deep learning model and the original data processing model into a plurality of layer groups respectively; wherein each layer group in the pre-trained deep learning model corresponds to each other in the original data processing model;
[0018] Obtain a first training data set, and for each layer group of the original data processing model, perform hierarchical training on the targeted layer group according to the first training data set, the pre-trained deep learning model, and the target layer group corresponding to the targeted layer group, until the hierarchical training of all layer groups of the original data processing model is completed, thereby obtaining an intermediate data processing model;
[0019] The pre-trained deep learning model and the intermediate data processing model are cross-layered to obtain a plurality of cross-layer groups; the cross-layer groups include at least two first adjacent layer groups selected from the pre-trained deep learning model, and at least two second adjacent layer groups selected from the intermediate data processing model corresponding to the at least two first adjacent layer groups;
[0020] Obtain a second training data set, and for each cross-layer group in the multiple cross-layer groups, perform distillation training on the at least two second adjacent layer groups in the cross-layer group according to the second training data set and the at least two first adjacent layer groups in the cross-layer group, until each of the cross-layer groups meets the model training end condition, thereby obtaining a trained target data processing model.
[0021] In a fourth aspect, the present application further provides a computer-readable storage medium having a computer program stored thereon, wherein when the computer program is executed by a processor, the following steps are implemented:
[0022] Dividing the pre-trained deep learning model and the original data processing model into a plurality of layer groups respectively; wherein each layer group in the pre-trained deep learning model corresponds to each other in the original data processing model;
[0023] Obtain a first training data set, and for each layer group of the original data processing model, perform hierarchical training on the targeted layer group according to the first training data set, the pre-trained deep learning model, and the target layer group corresponding to the targeted layer group, until the hierarchical training of all layer groups of the original data processing model is completed, thereby obtaining an intermediate data processing model;
[0024] The pre-trained deep learning model and the intermediate data processing model are cross-layered to obtain a plurality of cross-layer groups; the cross-layer groups include at least two first adjacent layer groups selected from the pre-trained deep learning model, and at least two second adjacent layer groups selected from the intermediate data processing model corresponding to the at least two first adjacent layer groups;
[0025] Obtain a second training data set, and for each cross-layer group in the multiple cross-layer groups, perform distillation training on the at least two second adjacent layer groups in the cross-layer group according to the second training data set and the at least two first adjacent layer groups in the cross-layer group, until each of the cross-layer groups meets the model training end condition, thereby obtaining a trained target data processing model.
[0026] In a fifth aspect, the present application further provides a computer program product, including a computer program, which implements the following steps when executed by a processor:
[0027] Dividing the pre-trained deep learning model and the original data processing model into a plurality of layer groups respectively; wherein each layer group in the pre-trained deep learning model corresponds to each other in the original data processing model;
[0028] Obtain a first training data set, and for each layer group of the original data processing model, perform hierarchical training on the targeted layer group according to the first training data set, the pre-trained deep learning model, and the target layer group corresponding to the targeted layer group, until the hierarchical training of all layer groups of the original data processing model is completed, thereby obtaining an intermediate data processing model;
[0029] The pre-trained deep learning model and the intermediate data processing model are cross-layered to obtain a plurality of cross-layer groups; the cross-layer groups include at least two first adjacent layer groups selected from the pre-trained deep learning model, and at least two second adjacent layer groups selected from the intermediate data processing model corresponding to the at least two first adjacent layer groups;
[0030] Obtain a second training data set, and for each cross-layer group in the multiple cross-layer groups, perform distillation training on the at least two second adjacent layer groups in the cross-layer group according to the second training data set and the at least two first adjacent layer groups in the cross-layer group, until each of the cross-layer groups meets the model training end condition, thereby obtaining a trained target data processing model.
[0031] In the above-mentioned model processing method, apparatus, computer equipment, computer-readable storage medium and computer program product, the pre-trained deep learning model and the original data processing model are divided into multiple layer groups respectively, and for each layer group of the original data processing model, hierarchical training is performed on the targeted layer group according to the first training data set and the target layer group corresponding to the targeted layer group in the pre-trained deep learning model, until the hierarchical training of each layer group of the original data processing model is completed to obtain an intermediate data processing model, thereby realizing hierarchical training of the original data processing model according to the pre-trained deep learning model without fully loading all models, thereby reducing memory usage and resource consumption during the model training process. Moreover, since the distillation training of the original data processing model can be realized according to the output data of the pre-trained deep learning model, there is no need to reuse the training data to adjust the data processing model again, thereby improving the efficiency of the model hierarchical training processing. Furthermore, by cross-layering the pre-trained deep learning model and the intermediate data processing model, multiple cross-layer groups are obtained, and the obtained cross-layer groups include at least two first adjacent layer groups selected from the pre-trained deep learning model, and at least two second adjacent layer groups selected from the intermediate data processing model and corresponding to the at least two first adjacent layer groups. Then, for each cross-layer group in the multiple cross-layer groups, distillation training is performed on the at least two second adjacent layer groups in the cross-layer group according to the second training data set and the at least two first adjacent layer groups in the cross-layer group, until each cross-layer group meets the model training end condition, and a trained target data processing model is obtained. The intermediate data processing model is fine-tuned step by step by cross-block distillation. While retaining the model processing capability of the preset deep learning model, the performance degradation caused by the inability to end-to-end due to layered training is avoided, thereby further improving the model training processing efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0032] In order to more clearly illustrate the technical solutions in the embodiments of the present application or related technologies, the drawings required for use in the embodiments of the present application or related technical descriptions will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.
[0033] Figure 1An application environment diagram of a model processing method in an embodiment;
[0034] Figure 2 A schematic diagram of a flow chart of a model processing method in one embodiment;
[0035] Figure 3 A schematic diagram of the basic structure of a pre-trained deep learning model and an original data processing model in one embodiment;
[0036] Figure 4 A schematic diagram of the corresponding layer groups of a pre-trained deep learning model and an original data processing model in one embodiment;
[0037] Figure 5 A schematic diagram of the corresponding layer groups of a pre-trained deep learning model and an original data processing model in another embodiment;
[0038] Figure 6 A schematic diagram of a process for obtaining an intermediate data processing model in one embodiment;
[0039] Figure 7 A schematic diagram of performing layer-by-layer training on each layer group of an original data processing model in one embodiment;
[0040] Figure 8 A schematic diagram of a process of performing distillation training on at least two second adjacent layer groups in a cross layer group in one embodiment;
[0041] Fig. 9 A schematic diagram of performing distillation training on a cross-layer group in one embodiment;
[0042] Fig.10 is a structural block diagram of a model processing device in an embodiment;
[0043] Fig.11 FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION
[0044] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0045] The model processing method provided in the embodiment of the present application involves artificial intelligence technology and can be applied to various scenarios such as smart transportation, map navigation, assisted driving, and network media. Specifically, it can be applied to Figure 1In the application environment shown. Among them, the terminal 102 communicates with the server 104 through the network. The data storage system can store the data that the server 104 needs to process. The data storage system can be integrated on the server 104, or it can be placed on the cloud or other network servers. Among them, the terminal 102 can be, but is not limited to, various personal computers, laptops, smart phones, tablet computers, Internet of Things devices, portable wearable devices, and aircraft, etc. The Internet of Things devices can be smart speakers, smart TVs, smart air conditioners, smart car devices, and projection devices. Portable wearable devices can be smart watches, smart bracelets, and head-mounted devices. The head-mounted device can be a virtual reality (VR) device, an augmented reality (AR) device, smart glasses, etc. The server 104 can be an independent physical broadcast control server, or a broadcast control server cluster composed of multiple physical broadcast control servers, or a cloud broadcast control server that provides cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN, and basic cloud computing services such as big data and artificial intelligence platforms. The terminal 102 and the server 104 may be directly or indirectly connected via wired or wireless communication, which is not limited in the embodiments of the present application.
[0046] Among them, the terminal 102 and the server 104 can be used alone to execute the model processing method provided in the embodiment of the present application, and the terminal 102 and the server 104 can also cooperate to execute the model processing method provided in the embodiment of the present application. For example, taking the terminal 102 and the server 104 cooperating to execute the model processing method provided in the embodiment of the present application as an example, the server 104 divides the pre-trained deep learning model and the original data processing model into multiple layer groups, and each layer group in the pre-trained deep learning model and the original data processing model corresponds to each other, and obtains a first training data set, for each layer group of the original data processing model, according to the first training data set, the pre-trained deep learning model and the target layer group corresponding to the targeted layer group, hierarchical training is performed on the targeted layer group, until the hierarchical training of all layer groups of the original data processing model is completed, and an intermediate data processing model is obtained. Furthermore, the server 104 performs cross-layer processing on the pre-trained deep learning model and the intermediate data processing model to obtain multiple cross-layer groups, and each cross-layer group obtained includes at least two first adjacent layer groups selected from the pre-trained deep learning model, and at least two second adjacent layer groups selected from the intermediate data processing model corresponding to the at least two first adjacent layer groups, and obtains a second training data set, and for each cross-layer group in the multiple cross-layer groups, performs distillation training on at least two second adjacent layer groups in the cross-layer group according to the second training data set and the at least two first adjacent layer groups in the cross-layer group, until each cross-layer group meets the model training end condition, and obtains a trained target data processing model. Among them, the trained target data processing model can be used to perform a variety of different data processing operations such as identification or classification of the data to be processed fed back by the terminal 102 to obtain corresponding data processing results.
[0047] In an exemplary embodiment, Figure 2 As shown, a model processing method is provided, which is applied to Figure 1 The server 104 in the example is used as an example to illustrate the method, which includes the following steps S202 to S208. Among them:
[0048] Step S202: Divide the pre-trained deep learning model and the original data processing model into multiple layer groups respectively, and each layer group in the pre-trained deep learning model and the original data processing model corresponds one to one.
[0049] The raw data processing model to be trained and the pre-trained deep learning model can be a media data processing model based on a transformer model (i.e., a self-attention neural network model structure), such as an image processing model, a text processing model, an audio processing model, a video processing model, and a multimodal processing model. The media data can be any one or more of image data, text data, audio data, and video data.
[0050] For example, Figure 3 As shown, a basic structure diagram of a pre-trained deep learning model and a raw data processing model is provided. Figure 3 It can be seen that the basic structure of the pre-trained deep learning model and the original data processing model can be specifically an autoregressive transformer model, wherein the autoregressive transformer model includes multiple network layers (for example, network layer 1-layer1, ..., network layer n-layern, etc.), and the model needs to convert the input data into an embedding sequence, and then input the embedding sequence into the network layer (for example, network layer 1-layer1), each network layer will use a self-attention mechanism to process the embedding sequence, and then send the processed data to the feedforward neural network, and input the output data of the feedforward neural network into the next network layer (for example, network layer 2-layer2), until the output (i.e., output) is obtained after being processed by the last network layer (for example, network layer n-layern).
[0051] in, Figure 3 Each input shown in the figure belongs to a token (the basic data unit processed by the model, which can be a word, character, phrase, image fragment or sound fragment, etc.) in the input data received by the model. That is, from left to right, multiple inputs represent multiple tokens, and multiple tokens constitute the complete input data. The autoregressive transformer model, through the self-attention mechanism, will pay attention to each token in front of it for each token.
[0052] Specifically, according to the model hierarchy structure, the model layers of the pre-trained deep learning model are divided into multiple layer groups, and the model layers of the original data processing model are divided into multiple layer groups, and a one-to-one correspondence is further established between each layer group in the pre-trained deep learning model and each layer group in the original data processing model.
[0053] Furthermore, specifically according to the model hierarchy structure, at least every two consecutive model layers of the pre-trained deep learning model are divided into a layer group in turn to obtain multiple layer groups corresponding to the pre-trained deep learning model, and each model layer of the original data processing model is divided into a layer group in turn to obtain multiple layer groups corresponding to the original data processing model.
[0054] Among them, after obtaining multiple layer groups corresponding to the pre-trained deep learning model and multiple layer groups corresponding to the original data processing model, a one-to-one correspondence between the pre-trained deep learning model and each layer group in the original data processing model is further established in sequence according to the model hierarchy structure.
[0055] For example, Figure 4 As shown, the corresponding layer groups of the pre-trained deep learning model and the original data processing model are provided. Figure 4 It can be seen that specifically, at least two adjacent layers in the pre-trained deep learning model are compressed into one layer in the original data processing model, that is, a layer group obtained by dividing at least every two consecutive model layers in the pre-trained deep learning model and a layer group obtained by dividing each model layer in the original data processing model are matched, thereby reducing the number of model layers and the number of layered training times, further improving the model training processing efficiency.
[0056] In an exemplary embodiment, Figure 5 As shown, another basic structure diagram of the pre-trained deep learning model and the original data processing model is provided. Figure 5 It can be seen that it is also possible to take a model layer in the pre-trained deep learning model as a layer group and a model layer in the original data processing model as a layer group, and establish a one-to-one correspondence between each layer group in the pre-trained deep learning model and each layer group in the original data processing model, so as to achieve the purpose of consistent number of model layers in the pre-trained deep learning model and the original data processing model, so that each model layer of the pre-trained deep learning model can be used in turn according to the model structure to train each model layer in the original data processing model.
[0057] Step S204, obtain the first training data set, and for each layer group of the original data processing model, perform hierarchical training on the targeted layer group according to the first training data set, the pre-trained deep learning model, and the target layer group corresponding to the targeted layer group, until the hierarchical training of all layer groups of the original data processing model is completed to obtain an intermediate data processing model.
[0058] Specifically, a first training data set is constructed by acquiring any one or more media data such as image data, text data, audio data, and video data, and the first training data set is input into a pre-trained deep learning model and a target layer group corresponding to the targeted layer group to obtain a first data processing result output by the target layer group for the first training data set.
[0059] The pre-trained deep learning model can be an image processing model, a text processing model, an audio processing model, a video processing model, and a multimodal processing model, that is, the pre-trained deep learning model can perform a series of processing such as recognition, noise reduction, and classification on image data, text data, audio data, and video data, respectively. When the pre-trained deep learning model is a multimodal processing model, it can perform processing such as recognition and fusion on image data, text data, audio data, and video data, etc.
[0060] Further, for each layer group of the original data processing model, hierarchical training is performed on the targeted layer group according to the first training data set and the first data processing result outputted by the target layer group in the pre-trained deep learning model and corresponding to the targeted layer group. When performing hierarchical training on the targeted layer group, the first data processing result outputted by the target layer group in the pre-trained deep learning model and corresponding to the targeted layer group is specifically used as a supervisory signal to fine-tune the model parameters of the targeted layer, including fine-tuning the model parameter values and the hidden layer dimensions of the model layer.
[0061] By performing layered training on each layer group of the original data processing model until the layered training of all layer groups of the original data processing model is completed, an intermediate data processing model after the layered training is obtained. The original data processing model can specifically be an image processing model, a text processing model, an audio processing model, a video processing model, and a multimodal processing model, that is, the original data processing model can specifically perform a series of processing such as recognition, noise reduction, and classification on image data, text data, audio data, and video data, respectively. When the original data processing model is a multimodal processing model, it can perform processing such as recognition and fusion on image data, text data, audio data, and video data.
[0062] Step S206, cross-layering is performed on the pre-trained deep learning model and the intermediate data processing model to obtain multiple cross-layer groups, where the cross-layer groups include at least two first adjacent layer groups selected from the pre-trained deep learning model, and at least two second adjacent layer groups selected from the intermediate data processing model corresponding to the at least two first adjacent layer groups.
[0063] Specifically, a plurality of layer groups in the pre-trained deep learning model and a plurality of layer groups in the intermediate data processing model are cross-layered to obtain a plurality of cross-layer groups, wherein each cross-layer group obtained includes at least two first adjacent layer groups selected from the pre-trained deep learning model and at least two second adjacent layer groups selected from the intermediate data processing model corresponding to the at least two first adjacent layer groups.
[0064] Among them, at least two first adjacent layer groups correspond to at least two second adjacent layer groups, which can be understood as at least two first adjacent layer groups and at least two second adjacent layer groups being in the same position in the model hierarchy structure, or the layer group numbers set for at least two first adjacent layer groups and at least two second adjacent layer groups being in one-to-one correspondence.
[0065] Exemplarily, taking the case where both the pre-trained deep learning model and the intermediate data processing model include three layer groups, the pre-trained deep learning model specifically includes layer group 1, layer group 2, and layer group 3, and the intermediate data processing model specifically includes layer group 1', layer group 2', and layer group 3', wherein layer group 1 corresponds to layer group 1', layer group 2 corresponds to layer group 2', and layer group 3 corresponds to layer group 3'. Specifically, the adjacent layer groups 1 and 2 in the pre-trained deep learning model, and the adjacent layer groups 1' and 2' in the intermediate data processing model are determined as a cross-layer group. Similarly, the adjacent layer groups 2 and 3 in the pre-trained deep learning model, and the adjacent layer groups 2' and 3' in the intermediate data processing model are also determined as a cross-layer group.
[0066] It can be understood that the pre-trained deep learning model and the intermediate data processing model may include multiple layer groups, not limited to one or some specific values. Correspondingly, multiple cross-layer groups can be obtained through cross-layer processing. For example, the adjacent layer group 1 and layer group 2 in the pre-trained deep learning model, and the adjacent layer group 1' and layer group 2' in the intermediate data processing model are determined as a cross-layer group; the adjacent layer group 2 and layer group 3 in the pre-trained deep learning model, and the adjacent layer group 2' and layer group 3' in the intermediate data processing model are determined as a cross-layer group; ...; and the adjacent layer group n-1 and layer group n in the pre-trained deep learning model, and the adjacent layer group n-1' and layer group n' in the intermediate data processing model are determined as a cross-layer group.
[0067] Step S208, obtain a second training data set, and for each cross-layer group in the multiple cross-layer groups, perform distillation training on at least two second adjacent layer groups in the cross-layer group according to the second training data set and at least two first adjacent layer groups in the cross-layer group, until each cross-layer group meets the model training end condition, thereby obtaining a trained target data processing model.
[0068] Specifically, a second training data set is constructed by acquiring any one or more media data such as image data, text data, audio data, and video data. For each cross-layer group in a plurality of cross-layer groups, the second training data set is input into a first layer group in at least one first adjacent layer group in the targeted cross-layer group to obtain a first distillation processing result output by each layer group in at least one first adjacent layer group.
[0069] Further, for each cross-layer group in the plurality of cross-layer groups, the second training data set and the first distillation processing result output for each layer group in at least one first adjacent layer group in the cross-layer group are input into at least two second adjacent layer groups in the cross-layer group to perform distillation training on the at least two second adjacent layer groups in the cross-layer group. Wherein, when performing distillation training on at least two second adjacent layer groups in the cross-layer group, specifically, the first distillation processing result output for each layer group in at least one first adjacent layer group in the cross-layer group is used as a supervisory signal to fine-tune the model parameters of at least two second adjacent layer groups in the cross-layer group, including fine-tuning the model parameter values and the hidden layer dimensions of the model layer.
[0070] The trained target data processing model is obtained by performing distillation training on at least two second adjacent layer groups in each cross-layer group until the distillation training of all cross-layer groups is completed, that is, when each cross-layer group satisfies the model training end condition. The trained target data processing model can specifically be a trained image processing model, text processing model, audio processing model, video processing model, and multimodal processing model.
[0071] In an exemplary embodiment, after obtaining the trained target data processing model, the method further includes:
[0072] The model parameters of the trained target data processing model are obtained, and the model parameters of the target data processing model are linearly quantized, the model parameters of the target data processing model are linearly mapped from floating-point values to an integer range, and the target data processing model after parameter quantization is obtained.
[0073] Specifically, by obtaining the model parameters of the trained target data processing model, the model parameters of the target data processing model are linearly quantized by using a linear quantization method. The linear quantization of the model parameters of the target data processing model specifically involves linearly mapping the model parameters of the target data processing model from floating point values to an integer range.
[0074] For example, the following formula (1) is specifically used to linearly map the model parameters from floating point values to integer ranges:
[0075] Formula (1);
[0076] Where x is the model parameter in the target data processing model, not limited to a specific parameter, Q(x) represents the integer value of the determined model parameter, and round() represents the rounding operation. val The minimum value of the floating-point value of the model parameter of the target data processing model, max val is the maximum floating-point value of the model parameter of the target data processing model, then [min val , max val ] is the floating point value range of the model parameters of the target data processing model, and 2 N-1 N in the figure represents the quantization bit width (for example, 8 bits or 4 bits), then the floating point value range [min val , max val ], linearly mapped to the integer range [0, 2 N-1 ].
[0077] It can be understood that by compressing the model parameters from floating point representation (such as FP16) to low-precision integer representation (such as INT8 or INT4), the storage requirements of the model parameters can be significantly reduced, thereby reducing the memory usage and computing resource consumption during model inference, and further improving the model training processing efficiency.
[0078] In the above-mentioned model processing method, the pre-trained deep learning model and the original data processing model are divided into multiple layer groups respectively, and for each layer group of the original data processing model, hierarchical training is performed on the targeted layer group according to the first training data set and the target layer group corresponding to the targeted layer group in the pre-trained deep learning model, until the hierarchical training of each layer group of the original data processing model is completed to obtain an intermediate data processing model, thereby realizing the hierarchical training of the original data processing model according to the pre-trained deep learning model without fully loading all models, reducing memory usage and resource consumption during the model training process, and because the distillation training of the original data processing model can be realized according to the output data of the pre-trained deep learning model, there is no need to reuse the training data to adjust the data processing model again, thereby improving the model hierarchical training processing efficiency. Furthermore, by cross-layering the pre-trained deep learning model and the intermediate data processing model, multiple cross-layer groups are obtained, and the obtained cross-layer groups include at least two first adjacent layer groups selected from the pre-trained deep learning model, and at least two second adjacent layer groups selected from the intermediate data processing model and corresponding to the at least two first adjacent layer groups. Then, for each cross-layer group in the multiple cross-layer groups, distillation training is performed on the at least two second adjacent layer groups in the cross-layer group according to the second training data set and the at least two first adjacent layer groups in the cross-layer group, until each cross-layer group meets the model training end condition, and a trained target data processing model is obtained. The intermediate data processing model is fine-tuned step by step by cross-block distillation. While retaining the model processing capability of the preset deep learning model, the performance degradation caused by the inability to end-to-end due to layered training is avoided, thereby further improving the model training processing efficiency.
[0079] In an exemplary embodiment, Figure 6 As shown, the step of obtaining the intermediate data processing model, that is, obtaining the first training data set, for each layer group of the original data processing model, according to the first training data set, the pre-trained deep learning model and the target layer group corresponding to the targeted layer group, hierarchical training is performed on the targeted layer group until the hierarchical training of all layer groups of the original data processing model is completed, and the step of obtaining the intermediate data processing model specifically includes the following steps S602 to S604. Among them:
[0080] Step S602, obtain a first training data set, input the first training data set into a pre-trained deep learning model and a target layer group corresponding to the targeted layer group, perform data processing on the first training data set through the target layer group, and obtain a first data processing result output by the target layer group.
[0081] Specifically, for each layer group in the original data processing model, a first training data set is constructed by acquiring any one or more media data such as image data, text data, audio data, and video data, and the first training data set is input into the pre-trained deep learning model and the target layer group corresponding to the targeted layer group, so as to perform data processing such as recognition, denoising and classification on the first training data set through the target layer group to obtain a first data processing result output by the target layer group.
[0082] Exemplarily, the following formula (2) is used to represent the first data processing result output by the target layer:
[0083] Formula (2);
[0084] Among them, y l+1 represents the first data processing result of the target layer group output, Teacher_net represents the layer group in the pre-trained deep learning model, and y l Represents the first training data set.
[0085] Step S604, for each layer group of the original data processing model, fix the model parameters of other layer groups, and perform hierarchical training on the model parameters of the targeted layer groups according to the first training data set and the first data processing results of the target layer group, until the hierarchical training of all layer groups of the original data processing model is completed to obtain an intermediate data processing model.
[0086] Specifically, for each layer group of the original data processing model, the model parameters of other layer groups are fixed, and the first training data set, the first data processing result of the target layer group, and the preset first alignment matrix are input into the targeted layer group to obtain the second data processing result output by the targeted layer group. The first data processing result of the target layer group is specifically input into the targeted layer of the original data processing model as a supervisory signal, and is used to optimize the model parameters of the targeted layer according to the supervisory signal.
[0087] Exemplarily, the following formula (3) is used to obtain the second data processing result output for the layer group:
[0088] Formula (3);
[0089] Among them, y student is the second data processing result output by the targeted layer group, Student_net represents the layer group in the original data processing model, Matmul() represents the multiplication operation, and y l represents the first training data set, Represents the preset first alignment matrix The transposed matrix of .
[0090] For example, if the hidden_size of the pre-trained deep learning model is 32768, and in each layer of the network, the dimensions of the multi-head attention module and the feed forward neural network module are both 32768, and the hidden_size in the original data processing model is 4096, and the dimensions of the multi-head attention module and the feed forward neural network module are both 4096, then the preset first alignment matrix can be set The dimension of is (32768, 4096), so as to align the dimensions of the outputs of the two models during training using the preset first alignment matrix.
[0091] Furthermore, by obtaining a preset second alignment matrix, multiplying the second data processing result of the targeted layer group and the preset second alignment matrix, the first matrix product result is obtained, and the layered training loss between the first matrix product result and the first data processing result of the target layer group is determined.
[0092] Exemplarily, the first matrix product result is determined by the following formula (4):
[0093] Formula (4);
[0094] in, Represents the first matrix multiplication result, Matmul() represents the product operation, Represents the preset second alignment matrix, y student Indicates the second data processing result output by the layer group. Similarly, if the hidden_size of the pre-trained deep learning model is 32768, and in each layer of the network, the dimensions of the multi-head attention module and the feedforward neural network module are both 32768, and the hidden_size in the original data processing model is 4096, and the dimensions of the multi-head attention module and the feedforward neural network module are both 4096, then the preset second alignment matrix is also set The dimension of is (32768, 4096), so as to align the dimensions of the outputs of the two models during training using the preset second alignment matrix.
[0095] Exemplarily, the following formula (5) is specifically used to determine the hierarchical training loss between the first matrix product result and the first data processing result of the target layer group:
[0096] Formula (5);
[0097] Among them, loss 1 represents the layer-wise training loss, Represents the result of the first matrix multiplication, y l+1represents the first data processing result output by the target layer group, and cosine_embedding_loss() represents the cosine embedding loss function. Among them, other loss functions, such as mean square error loss, can also be used to determine the hierarchical training loss between the first matrix product result and the first data processing result of the target layer group.
[0098] Furthermore, if the layered training loss satisfies the layered training termination condition, the layered training for the targeted layer group is completed. The layered training termination condition may specifically be that the determined layered training loss value reaches a preset layered training loss threshold.
[0099] In an exemplary embodiment, Figure 7 As shown, a schematic diagram of layered training for each layer group of the original data processing model is provided, referring to Figure 7 It can be seen that taking the example that both the pre-trained deep learning model and the intermediate data processing model include 3 layer groups, the pre-trained deep learning model specifically includes layer group 1, layer group 2, and layer group 3, and the intermediate data processing model specifically includes layer group 1', layer group 2', and layer group 3', among which layer group 1 corresponds to layer group 1', layer group 2 corresponds to layer group 2', and layer group 3 corresponds to layer group 3'.
[0100] Specifically, by taking layer group 1 and layer group 1', layer group 2 and layer group 2', and layer group 3 and layer group 3' as a training block respectively, block training is realized, that is, layer group 1 is used to train layer group 1', layer group 2 is used to train layer group 2', and layer group 3 is used to train layer group 3'. Among them, for the training blocks of layer group 1 and layer group 1', the training blocks of layer group 2 and layer group 2', and the training blocks of layer group 3 and layer group 3', their respective input data (i.e., input) can be constructed respectively, and the layered training loss between the output data of layer group 1 and the output data of layer group 1', the layered training loss between the output data of layer group 2 and the output data of layer group 2', and the layered training loss between the output data of layer group 3 and the output data of layer group 3' are calculated respectively, so as to achieve the purpose of layered training.
[0101] In this embodiment, by obtaining a first training data set, the first training data set is input into a pre-trained deep learning model and a target layer group corresponding to the targeted layer group, and data processing is performed on the first training data set through the target layer group to obtain a first data processing result output by the target layer group. Furthermore, for each layer group of the original data processing model, the model parameters of other layer groups are fixed, and the model parameters of the targeted layer group are layered trained according to the first training data set and the first data processing result of the target layer group until the layered training of all layer groups of the original data processing model is completed to obtain an intermediate data processing model, thereby achieving the purpose of training each layer group of the original data processing model separately without fully loading all models, reducing memory usage and resource consumption during model training, and because the distillation training of the original data processing model can be achieved based on the output data of the pre-trained deep learning model, there is no need to reuse the training data to adjust the data processing model again, thereby improving the efficiency of model layered training processing.
[0102] In an exemplary embodiment, Figure 8 As shown, the step of performing distillation training on at least two second adjacent layer groups in the cross layer group, that is, obtaining a second training data set, for each cross layer group in the multiple cross layer groups, according to the second training data set and at least two first adjacent layer groups in the cross layer group, performing distillation training on at least two second adjacent layer groups in the cross layer group, specifically includes the following steps S802 to S804. Wherein:
[0103] Step S802, obtaining a second training data set, inputting the second training data set into a first layer group in at least one first adjacent layer group in the targeted cross layer group, and obtaining a first distillation processing result output by each layer group in at least one first adjacent layer group.
[0104] Specifically, a second training data set is constructed by acquiring any one or more media data such as image data, text data, audio data, and video data. For each cross-layer group in a plurality of cross-layer groups, the second training data set is input into a first layer group in at least one first adjacent layer group in the targeted cross-layer group. Through the first layer group in at least one first adjacent layer group, data processing such as recognition, denoising, and classification is performed on the second training data set to obtain a first distillation processing result output by each layer group in at least one first adjacent layer group.
[0105] Exemplarily, the following formula (6) is used to represent the first distillation processing result output by each layer group in at least one first adjacent layer group:
[0106] Formula (6);
[0107] Among them, ym+1 represents the first distillation processing result of each layer group output in at least one first adjacent layer group, Teacher_net represents at least one first adjacent layer group belonging to the pre-trained deep learning model in the cross layer group, y m Represents the second training data set.
[0108] Step S804: performing distillation training on each layer group in at least one second adjacent layer group according to the second training data set and the first distillation processing result output by each layer group in at least one first adjacent layer group.
[0109] Specifically, the second training data set is input into the first layer group of at least one second adjacent layer group in the cross layer group, and the first alignment matrix and the first distillation processing result of each layer group in at least one first adjacent layer group are respectively input into each layer group in at least one second adjacent layer group, thereby obtaining the second distillation processing result output by each layer group in at least one second adjacent layer group. The first distillation processing result of each layer group in at least one first adjacent layer group is specifically input into each layer group in at least one second adjacent layer group as a supervisory signal, so as to optimize the model parameters of each layer group in at least one second adjacent layer group according to the supervisory signal.
[0110] Exemplarily, the second distillation processing result output by each layer group in at least one second adjacent layer group is specifically expressed by the following formula (7):
[0111] Formula (7);
[0112] in, is the second distillation processing result output by each layer group in at least one second adjacent layer group, Student_net represents at least one second adjacent layer group belonging to the original data processing model in the cross layer group, Matmul() represents the product operation, y m represents the second training data set, Represents the preset first alignment matrix The transposed matrix of .
[0113] Furthermore, by obtaining the second distillation processing result of the last layer group in at least one second adjacent layer group, multiplying the second distillation processing result of the last layer group in at least one second adjacent layer group and the second alignment matrix to obtain a second matrix product result, and determining the distillation training loss between the first distillation processing result of the last layer group in at least one first adjacent layer group and the second matrix product result. Specifically, the distillation training loss can be calculated by using a cosine embedding loss function, a mean square error loss function, etc., to calculate a cosine embedding loss value, a mean square error loss value, etc., between the first distillation processing result of the last layer group in at least one first adjacent layer group and the second matrix product result.
[0114] Exemplarily, the second matrix product result is specifically expressed by the following formula (8):
[0115] Formula (8);
[0116] in, Indicates the second matrix product result, Matmul() indicates the product operation, Represents the preset second alignment matrix, The second distillation treatment result of the last layer group in at least one second adjacent layer group.
[0117] Exemplarily, the following formula (9) is specifically used to determine the distillation training loss between the first distillation processing result of the last layer group in at least one first adjacent layer group and the second matrix product result:
[0118] Formula (9);
[0119] Among them, loss 2 represents the distillation training loss, Represents the result of the second matrix product, y m+1 represents the first distillation processing result of the last layer group in at least one first adjacent layer group, and cosine_embedding_loss() represents the cosine embedding loss function. Among them, other loss functions, such as mean square error loss, can also be used to determine the layer-wise training loss between the first matrix product result and the first data processing result of the target layer group.
[0120] If the distillation training loss satisfies the distillation training termination condition, the distillation training for the cross-layer group is completed. For example, the distillation training termination condition may be that the determined distillation training loss value reaches a preset distillation training loss threshold.
[0121] In an exemplary embodiment, Fig. 9As shown, a schematic diagram of distillation training for cross-layer groups is provided, referring to Fig. 9 It can be seen that taking the example that both the pre-trained deep learning model and the intermediate data processing model include 3 layer groups, the pre-trained deep learning model specifically includes layer group 1, layer group 2, and layer group 3, and the intermediate data processing model specifically includes layer group 1', layer group 2', and layer group 3', among which layer group 1 corresponds to layer group 1', layer group 2 corresponds to layer group 2', and layer group 3 corresponds to layer group 3'.
[0122] Specifically, refer to Fig. 9 It can be seen that specifically, the adjacent layer group 1 and layer group 2 in the pre-trained deep learning model, and the adjacent layer group 1' and layer group 2' in the intermediate data processing model are determined as the first cross-layer group, and the adjacent layer group 2 and layer group 3 in the pre-trained deep learning model, and the adjacent layer group 2' and layer group 3' in the intermediate data processing model are determined as the second cross-layer group.
[0123] Among them, refer to Fig. 9 It can be seen that for the first cross-layer group and the second cross-layer group, the corresponding input data must be constructed respectively (that is, the second training data set must be constructed respectively), and the distillation training losses of the first cross-layer group and the second cross-layer group must be calculated respectively, so as to judge whether the first cross-layer group and the second cross-layer group meet the distillation training end conditions according to the distillation training losses of the first cross-layer group and the second cross-layer group.
[0124] In this implementation, a second training data set is obtained, and the second training data set is input into the first layer group in at least one first adjacent layer group in the targeted cross-layer group to obtain a first distillation processing result output by each layer group in at least one first adjacent layer group. Based on the second training data set and the first distillation processing result output by each layer group in at least one first adjacent layer group, distillation training is performed on each layer group in at least one second adjacent layer group, thereby realizing step-by-step fine-tuning of the intermediate data processing model by means of cross-block distillation. While retaining the model processing capability of the preset deep learning model, the performance degradation problem caused by the inability to end-to-end due to the early layered training is avoided, thereby further improving the model training processing efficiency.
[0125] In an exemplary embodiment, an overall processing process of a model processing method is provided, which specifically includes processing steps such as P1 model stratification, P2 stratification training, P3 cross stratification, P4 cross stratification distillation training, and P5 model parameter quantization, wherein:
[0126] P1. Model stratification:
[0127] 1) According to the model hierarchy structure, at least every two consecutive model layers of the pre-trained deep learning model are divided into a layer group in turn to obtain a plurality of layer groups corresponding to the pre-trained deep learning model, and each model layer of the original data processing model is divided into a layer group in turn to obtain a plurality of layer groups corresponding to the original data processing model;
[0128] 2) According to the model hierarchy, the correspondence between the pre-trained deep learning model and the layer groups in the original data processing model is established in sequence, so that each layer group in the pre-trained deep learning model and the original data processing model corresponds one to one.
[0129] P2, layered training:
[0130] 1) Obtain a first training data set, input the first training data set into a pre-trained deep learning model and a target layer group corresponding to the targeted layer group, perform data processing on the first training data set through the target layer group, and obtain a first data processing result output by the target layer group.
[0131] 2) For each layer group of the original data processing model, the model parameters of other layer groups are fixed, and the first training data set, the first data processing result of the target layer group, and the preset first alignment matrix are input into the targeted layer group to obtain the second data processing result output by the targeted layer group.
[0132] 3) Multiply the second data processing result of the targeted layer group by the preset second alignment matrix to obtain the first matrix product result, and determine the layered training loss between the first matrix product result and the first data processing result of the target layer group. If the layered training loss meets the layered training end condition, the layered training of the targeted layer group is completed.
[0133] 4) If the hierarchical training of all layer groups of the original data processing model is completed, the intermediate data processing model is obtained.
[0134] P3, cross-layering:
[0135] The pre-trained deep learning model and the intermediate data processing model are cross-layered to obtain multiple cross-layer groups. The cross-layer groups include at least two first adjacent layer groups selected from the pre-trained deep learning model and at least two second adjacent layer groups selected from the intermediate data processing model corresponding to the at least two first adjacent layer groups.
[0136] P4, cross-layer distillation training:
[0137] 1) Obtain a second training data set, and for each cross-layer group in a plurality of cross-layer groups, input the second training data set into a first layer group in at least one first adjacent layer group in the cross-layer group to obtain a first distillation processing result output by each layer group in at least one first adjacent layer group.
[0138] 2) inputting the second training data set into the first layer group of at least one second adjacent layer group in the targeted cross layer group, and inputting the first alignment matrix and the first distillation processing result of each layer group in at least one first adjacent layer group into each layer group in at least one second adjacent layer group, respectively, to obtain the second distillation processing result output by each layer group in at least one second adjacent layer group;
[0139] 3) Multiply the second distillation processing result of the last layer group in at least one second adjacent layer group and the second alignment matrix to obtain a second matrix product result, and determine the distillation training loss between the first distillation processing result of the last layer group in at least one first adjacent layer group and the second matrix product result. If the distillation training loss meets the distillation training end condition, the distillation training for the cross-layer group is completed.
[0140] 4) If all cross-layer groups meet the model training end conditions, the trained target data processing model is obtained.
[0141] P5. Model parameter quantification:
[0142] The model parameters of the trained target data processing model are obtained, the model parameters of the target data processing model are linearly quantized, the model parameters of the target data processing model are linearly mapped from floating-point values to an integer range, and the target data processing model after parameter quantization is obtained.
[0143] In the above-mentioned model processing method, the pre-trained deep learning model and the original data processing model are divided into multiple layer groups respectively, and for each layer group of the original data processing model, hierarchical training is performed on the targeted layer group according to the first training data set and the target layer group corresponding to the targeted layer group in the pre-trained deep learning model, until the hierarchical training of each layer group of the original data processing model is completed to obtain an intermediate data processing model, thereby realizing the hierarchical training of the original data processing model according to the pre-trained deep learning model without fully loading all models, reducing memory usage and resource consumption during the model training process, and because the distillation training of the original data processing model can be realized according to the output data of the pre-trained deep learning model, there is no need to reuse the training data to adjust the data processing model again, thereby improving the model hierarchical training processing efficiency. Furthermore, by cross-layering the pre-trained deep learning model and the intermediate data processing model, multiple cross-layer groups are obtained, and the obtained cross-layer groups include at least two first adjacent layer groups selected from the pre-trained deep learning model, and at least two second adjacent layer groups selected from the intermediate data processing model and corresponding to the at least two first adjacent layer groups. Then, for each cross-layer group in the multiple cross-layer groups, distillation training is performed on the at least two second adjacent layer groups in the cross-layer group according to the second training data set and the at least two first adjacent layer groups in the cross-layer group, until each cross-layer group meets the model training end condition, and a trained target data processing model is obtained. The intermediate data processing model is fine-tuned step by step by cross-block distillation. While retaining the model processing capability of the preset deep learning model, the performance degradation caused by the inability to end-to-end due to layered training is avoided, thereby further improving the model training processing efficiency.
[0144] It should be understood that, although the steps in the flowcharts involved in the above embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps is not strictly limited in order, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above embodiments may include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.
[0145] Based on the same inventive concept, the embodiment of the present application also provides a model processing device for implementing the model processing method involved above. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above method, so the specific limitations in one or more model processing device embodiments provided below can refer to the limitations on the model processing method above, and will not be repeated here.
[0146] In an exemplary embodiment, Fig.10 As shown, a model processing device is provided, including: a layer group division module 1002, a layered training module 1004, a cross-layered module 1006 and a distillation training module 1008, wherein:
[0147] A layer group division module 1002 is used to divide the pre-trained deep learning model and the original data processing model into a plurality of layer groups respectively; each layer group in the pre-trained deep learning model and the original data processing model corresponds one to one;
[0148] The hierarchical training module 1004 is used to obtain a first training data set, and for each layer group of the original data processing model, perform hierarchical training on the targeted layer group according to the first training data set, the pre-trained deep learning model and the target layer group corresponding to the targeted layer group, until the hierarchical training of all layer groups of the original data processing model is completed to obtain an intermediate data processing model;
[0149] A cross-layer module 1006 is used to perform cross-layer processing on the pre-trained deep learning model and the intermediate data processing model to obtain multiple cross-layer groups; the cross-layer groups include at least two first adjacent layer groups selected from the pre-trained deep learning model, and at least two second adjacent layer groups selected from the intermediate data processing model corresponding to the at least two first adjacent layer groups;
[0150] The distillation training module 1008 is used to obtain a second training data set, and for each cross-layer group in the multiple cross-layer groups, perform distillation training on at least two second adjacent layer groups in the cross-layer group according to the second training data set and at least two first adjacent layer groups in the cross-layer group, until each cross-layer group meets the model training end condition, thereby obtaining a trained target data processing model.
[0151] In the above-mentioned model processing device, by dividing the pre-trained deep learning model and the original data processing model into multiple layer groups respectively, for each layer group of the original data processing model, hierarchical training is performed on the targeted layer group according to the first training data set and the target layer group corresponding to the targeted layer group in the pre-trained deep learning model, until the hierarchical training of each layer group of the original data processing model is completed, and an intermediate data processing model is obtained, thereby realizing the hierarchical training of the original data processing model according to the pre-trained deep learning model without fully loading all models, reducing memory usage and resource consumption in the model training process, and because the distillation training of the original data processing model can be realized according to the output data of the pre-trained deep learning model, there is no need to reuse the training data to adjust the data processing model again, thereby improving the model hierarchical training processing efficiency. Furthermore, by cross-layering the pre-trained deep learning model and the intermediate data processing model, multiple cross-layer groups are obtained, and the obtained cross-layer groups include at least two first adjacent layer groups selected from the pre-trained deep learning model, and at least two second adjacent layer groups selected from the intermediate data processing model and corresponding to the at least two first adjacent layer groups. Then, for each cross-layer group in the multiple cross-layer groups, distillation training is performed on the at least two second adjacent layer groups in the cross-layer group according to the second training data set and the at least two first adjacent layer groups in the cross-layer group, until each cross-layer group meets the model training end condition, and a trained target data processing model is obtained. The intermediate data processing model is fine-tuned step by step by cross-block distillation. While retaining the model processing capability of the preset deep learning model, the performance degradation caused by the inability to end-to-end due to layered training is avoided, thereby further improving the model training processing efficiency.
[0152] In an exemplary embodiment, the hierarchical training module is also used to: obtain a first training data set, input the first training data set into a pre-trained deep learning model and a target layer group corresponding to the targeted layer group, perform data processing on the first training data set through the target layer group, and obtain a first data processing result output by the target layer group; for each layer group of the original data processing model, fix the model parameters of other layer groups, and perform hierarchical training on the model parameters of the targeted layer group according to the first training data set and the first data processing results of the target layer group, until the hierarchical training of all layer groups of the original data processing model is completed to obtain an intermediate data processing model.
[0153] In an exemplary embodiment, the hierarchical training module is also used to: input the first training data set, the first data processing result of the target layer group, and the preset first alignment matrix into the targeted layer group to obtain the second data processing result output by the targeted layer group; multiply the second data processing result of the targeted layer group and the preset second alignment matrix to obtain the first matrix product result; determine the hierarchical training loss between the first matrix product result and the first data processing result of the target layer group; if the hierarchical training loss meets the hierarchical training end condition, complete the hierarchical training of the targeted layer group.
[0154] In an exemplary embodiment, the distillation training module is further used to: obtain a second training data set, input the second training data set into the first layer group in at least one first adjacent layer group in the targeted cross-layer group, and obtain a first distillation processing result output by each layer group in at least one first adjacent layer group; and perform distillation training on each layer group in at least one second adjacent layer group based on the second training data set and the first distillation processing result output by each layer group in at least one first adjacent layer group.
[0155] In an exemplary embodiment, the distillation training module is also used to: input the second training data set into the first layer group of at least one second adjacent layer group in the targeted cross-layer group, and input the first alignment matrix and the first distillation processing result of each layer group in at least one first adjacent layer group into each layer group in at least one second adjacent layer group, respectively, to obtain the second distillation processing result output by each layer group in at least one second adjacent layer group; multiply the second distillation processing result of the last layer group in at least one second adjacent layer group and the second alignment matrix to obtain the second matrix product result; determine the distillation training loss between the first distillation processing result of the last layer group in at least one first adjacent layer group and the second matrix product result; if the distillation training loss meets the distillation training end condition, the distillation training of the targeted cross-layer group is completed.
[0156] In an exemplary embodiment, the layer group division module is also used to: divide at least every two consecutive model layers of the pre-trained deep learning model into a layer group in accordance with the model hierarchy structure, so as to obtain multiple layer groups corresponding to the pre-trained deep learning model; and divide each model layer of the original data processing model into a layer group in accordance with the model hierarchy structure, so as to obtain multiple layer groups corresponding to the original data processing model; and establish the correspondence between the pre-trained deep learning model and the layer groups in the original data processing model in accordance with the model hierarchy structure.
[0157] In an exemplary embodiment, a model processing device is provided, further comprising a parameter quantization processing module, for:
[0158] Obtain the model parameters of the trained target data processing model; perform linear quantization on the model parameters of the target data processing model, linearly map the model parameters of the target data processing model from floating-point values to an integer range, and obtain the target data processing model after parameter quantization.
[0159] Each module in the above-mentioned model processing device can be implemented in whole or in part by software, hardware and a combination thereof. Each of the above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory in the computer device in the form of software, so that the processor can call and execute the operations corresponding to each of the above modules.
[0160] In an exemplary embodiment, a computer device is provided. The computer device may be a server or a terminal. Taking the computer device as a server as an example, its internal structure diagram may be as follows: Fig.11 As shown. The computer device includes a processor, a memory, an input / output interface (Input / Output, referred to as I / O) and a communication interface. Among them, the processor, the memory and the input / output interface are connected through a system bus, and the communication interface is connected to the system bus through the input / output interface. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store data such as a pre-trained deep learning model and multiple layer groups in the original data processing model, a first training data set, an intermediate data processing model, multiple cross-layers, at least two first adjacent layer groups selected from the pre-trained deep learning model, at least two second adjacent layer groups selected from the intermediate data processing model corresponding to at least two first adjacent layer groups, a second training data set, and a trained target data processing model. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by a processor, a model processing method is implemented.
[0161] Those skilled in the art will understand that Fig.11 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0162] In one embodiment, a computer device is further provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor implements the steps in the above method embodiments when executing the computer program.
[0163] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps in the above-mentioned method embodiments are implemented.
[0164] In one embodiment, a computer program product is provided, including a computer program, which implements the steps in the above method embodiments when executed by a processor.
[0165] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant regulations.
[0166] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in this application can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, an artificial intelligence (AI) processor, etc., but are not limited to this.
[0167] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this application.
[0168] The above embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.
Claims
1. A model processing method, It is characterized in that The method comprises: Dividing the pre-trained deep learning model and the original data processing model into a plurality of layer groups respectively; wherein each layer group in the pre-trained deep learning model corresponds to each other in the original data processing model; Obtain a first training data set, and for each layer group of the original data processing model, perform hierarchical training on the targeted layer group according to the first training data set, the pre-trained deep learning model, and the target layer group corresponding to the targeted layer group, until the hierarchical training of all layer groups of the original data processing model is completed, thereby obtaining an intermediate data processing model; The pre-trained deep learning model and the intermediate data processing model are cross-layered to obtain a plurality of cross-layer groups; the cross-layer groups include at least two first adjacent layer groups selected from the pre-trained deep learning model, and at least two second adjacent layer groups selected from the intermediate data processing model corresponding to the at least two first adjacent layer groups; Obtain a second training data set, and for each cross-layer group in the multiple cross-layer groups, perform distillation training on the at least two second adjacent layer groups in the cross-layer group according to the second training data set and the at least two first adjacent layer groups in the cross-layer group, until each of the cross-layer groups meets the model training end condition, thereby obtaining a trained target data processing model.
2. The method according to claim 1, It is characterized in that The step of obtaining a first training data set and, for each layer group of the original data processing model, performing layer-by-layer training on the targeted layer group according to the first training data set, the pre-trained deep learning model and the target layer group corresponding to the targeted layer group, until the layer-by-layer training of all layer groups of the original data processing model is completed to obtain an intermediate data processing model includes: Obtain a first training data set, input the first training data set into the pre-trained deep learning model and the target layer group corresponding to the targeted layer group, perform data processing on the first training data set through the target layer group, and obtain a first data processing result output by the target layer group; For each layer group of the original data processing model, the model parameters of other layer groups are fixed, and the model parameters of the targeted layer groups are subjected to hierarchical training according to the first training data set and the first data processing result of the target layer group, until the hierarchical training of all layer groups of the original data processing model is completed to obtain an intermediate data processing model.
3. The method according to claim 2, It is characterized in that According to the first training data set and the first data processing result of the target layer group, the model parameters of the target layer group are subjected to layer-by-layer training, including: Inputting the first training data set, the first data processing result of the target layer group, and a preset first alignment matrix into the targeted layer group to obtain a second data processing result outputted by the targeted layer group; Multiplying the second data processing result of the layer group and a preset second alignment matrix to obtain a first matrix product result; Determining a layer-wise training loss between the first matrix product result and a first data processing result of the target layer group; If the layer-by-layer training loss satisfies the layer-by-layer training termination condition, the layer-by-layer training for the targeted layer group is completed.
4. The method according to any one of claims 1 to 3, It is characterized in that The step of obtaining a second training data set and, for each cross layer group in the plurality of cross layer groups, performing distillation training on the at least two second adjacent layer groups in the cross layer group according to the second training data set and the at least two first adjacent layer groups in the cross layer group, comprises: Acquire a second training data set, input the second training data set into a first layer group in at least one first adjacent layer group in the targeted cross layer group, and obtain a first distillation processing result output by each layer group in the at least one first adjacent layer group; Distillation training is performed on each layer group in at least one second adjacent layer group according to the second training data set and the first distillation processing result output by each layer group in the at least one first adjacent layer group.
5. The method according to claim 4, It is characterized in that The step of performing distillation training on each layer group in at least one second adjacent layer group according to the second training data set and the first distillation processing result output by each layer group in the at least one first adjacent layer group comprises: Input the second training data set into the first layer group of at least one second adjacent layer group in the targeted cross layer group, and input the first alignment matrix and the first distillation processing result of each layer group in the at least one first adjacent layer group into each layer group in the at least one second adjacent layer group, respectively, to obtain the second distillation processing result output by each layer group in the at least one second adjacent layer group; multiplying the second distillation processing result of the last layer group in the at least one second adjacent layer group and the second alignment matrix to obtain a second matrix product result; Determining a distillation training loss between a first distillation processing result of a last layer group in the at least one first adjacent layer group and a second matrix product result; If the distillation training loss satisfies the distillation training end condition, the distillation training for the cross-layer group is completed.
6. The method according to any one of claims 1 to 3, It is characterized in that The pre-trained deep learning model and the original data processing model are divided into multiple layer groups, including: According to the model hierarchy structure, at least every two consecutive model layers of the pre-trained deep learning model are divided into a layer group in sequence to obtain a plurality of layer groups corresponding to the pre-trained deep learning model, and each model layer of the original data processing model is divided into a layer group in sequence to obtain a plurality of layer groups corresponding to the original data processing model; The method also includes: establishing the correspondence between the pre-trained deep learning model and the layer groups in the original data processing model in sequence according to the model hierarchy structure.
7. The method according to any one of claims 1 to 3, It is characterized in that The method further comprises: Obtain model parameters of the trained target data processing model; Linear quantization is performed on the model parameters of the target data processing model, and the model parameters of the target data processing model are linearly mapped from floating-point values to an integer range to obtain the target data processing model after parameter quantization.
8. A model processing device, It is characterized in that The device comprises: A layer group division module, used to divide the pre-trained deep learning model and the original data processing model into a plurality of layer groups respectively; each layer group in the pre-trained deep learning model and the original data processing model corresponds one to one; A hierarchical training module is used to obtain a first training data set, and for each layer group of the original data processing model, perform hierarchical training on the targeted layer group according to the first training data set, the pre-trained deep learning model and the target layer group corresponding to the targeted layer group, until the hierarchical training of all layer groups of the original data processing model is completed to obtain an intermediate data processing model; A cross-layering module, used to perform cross-layering processing on the pre-trained deep learning model and the intermediate data processing model to obtain a plurality of cross-layer groups; the cross-layer groups include at least two first adjacent layer groups selected from the pre-trained deep learning model, and at least two second adjacent layer groups selected from the intermediate data processing model corresponding to the at least two first adjacent layer groups; A distillation training module is used to obtain a second training data set, and for each cross-layer group in the multiple cross-layer groups, perform distillation training on the at least two second adjacent layer groups in the cross-layer group according to the second training data set and the at least two first adjacent layer groups in the cross-layer group, until each of the cross-layer groups meets the model training end condition, thereby obtaining a trained target data processing model.
9. The device according to claim 8, It is characterized in that The hierarchical training module is also used for: Acquire a first training data set, input the first training data set into the pre-trained deep learning model and the target layer group corresponding to the targeted layer group, perform data processing on the first training data set through the target layer group, and obtain a first data processing result output by the target layer group; for each layer group of the original data processing model, fix the model parameters of other layer groups, and perform hierarchical training on the model parameters of the targeted layer group according to the first training data set and the first data processing result of the target layer group, until the hierarchical training of all layer groups of the original data processing model is completed to obtain an intermediate data processing model.
10. The device according to claim 9, It is characterized in that The hierarchical training module is also used for: Inputting the first training data set, the first data processing result of the target layer group, and a preset first alignment matrix into the targeted layer group to obtain a second data processing result outputted by the targeted layer group; Multiplying the second data processing result of the layer group and a preset second alignment matrix to obtain a first matrix product result; Determine the hierarchical training loss between the first matrix multiplication result and the first data processing result of the target layer group; if the hierarchical training loss meets the hierarchical training end condition, complete the hierarchical training of the targeted layer group.
11. The device according to any one of claims 8 to 10, It is characterized in that The distillation training module is also used to: Acquire a second training data set, input the second training data set into a first layer group in at least one first adjacent layer group in the targeted cross layer group, and obtain a first distillation processing result output by each layer group in the at least one first adjacent layer group; Distillation training is performed on each layer group in at least one second adjacent layer group according to the second training data set and the first distillation processing result output by each layer group in the at least one first adjacent layer group.
12. The device according to claim 11, It is characterized in that The distillation training module is also used to: Input the second training data set into the first layer group of at least one second adjacent layer group in the targeted cross layer group, and input the first alignment matrix and the first distillation processing result of each layer group in the at least one first adjacent layer group into each layer group in the at least one second adjacent layer group, respectively, to obtain the second distillation processing result output by each layer group in the at least one second adjacent layer group; Multiply the second distillation processing result of the last layer group in the at least one second adjacent layer group and the second alignment matrix to obtain a second matrix product result; determine the distillation training loss between the first distillation processing result of the last layer group in the at least one first adjacent layer group and the second matrix product result; if the distillation training loss meets the distillation training end condition, complete the distillation training for the cross-layer group.
13. The device according to any one of claims 8 to 10, It is characterized in that The layer group division module is also used for: According to the model hierarchy structure, at least every two consecutive model layers of the pre-trained deep learning model are divided into a layer group in turn to obtain multiple layer groups corresponding to the pre-trained deep learning model, and each model layer of the original data processing model is divided into a layer group in turn to obtain multiple layer groups corresponding to the original data processing model; according to the model hierarchy structure, the correspondence between the pre-trained deep learning model and the layer groups in the original data processing model is established in turn.
14. The device according to any one of claims 8 to 10, It is characterized in that The device also includes a parameter quantization processing module, which is used to: Acquire the model parameters of the trained target data processing model; perform linear quantization processing on the model parameters of the target data processing model, linearly map the model parameters of the target data processing model from floating-point values to an integer range, and obtain the target data processing model after parameter quantization.
15. A computer device comprising a memory and a processor, wherein the memory stores a computer program. It is characterized in that When the processor executes the computer program, the steps of the method according to any one of claims 1 to 7 are implemented.
16. A computer-readable storage medium having a computer program stored thereon, It is characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.
17. A computer program product comprising a computer program, It is characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.
