Transform model collaborative reasoning method for multiple edge devices
By dividing the Transformer model into sub-models and executing them in parallel on multiple edge devices, combined with sub-task distillation and feature fusion modules, the problem of high edge device reasoning speed and energy consumption is solved, and efficient Transformer model collaborative reasoning is achieved. Balances accuracy and speed.
Patent Information
- Application Number
- CN202410844642.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-27
- Publication Date
- 2024-10-25
AI Technical Summary
The direct deployment of Transformer models on edge devices is limited by computing resources and memory constraints, resulting in high inference speed and energy consumption. Existing solutions such as edge-cloud collaboration and edge compression cannot effectively balance inference accuracy and speed.
The Transformer model is divided into multiple sub-models and deployed on multiple edge devices. Parallel reasoning is achieved through sub-task distillation and feature fusion modules, reducing communication overhead and computational complexity, and improving overall performance.
It significantly reduces the inference energy consumption and computing overhead of edge devices, while increasing the inference speed, and achieving a balance between inference accuracy and speed while ensuring minimal accuracy loss.
Smart Images

Figure CN118839766A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to a neural network reasoning method, and in particular to a Transformer model collaborative reasoning method for multiple edge devices, which belongs to the field of edge computing. Background Art
[0002] With the rapid development of high-tech technologies such as big data and artificial intelligence, Transformer, as a basic model in deep neural network (DNN), has achieved performance beyond human in most intelligent applications in the fields of computer vision, natural language processing and speech recognition. Considering the requirements of low latency and privacy, it is of great significance to deploy Transformer models on edge devices such as mobile phones and development boards to realize intelligent applications. However, the Transformer model has high computational complexity and large memory overhead, while edge devices usually have limited computing resources, and power and memory are much smaller than workstations or servers. Therefore, it is difficult to directly deploy Transformer models on edge devices to realize intelligent applications. Taking the classic visual Transformer model ViT-L / 16 as an example, it requires 5.3GB of memory and 123.1G floating-point operations for one inference, while the Raspberry Pi 4B+ edge device has only 4GB of memory space and a computing performance of 13.5G floating-point operations / second, so it is impossible to deploy Transformer to realize intelligent applications.
[0003] In response to the above problems, the current solutions mainly include edge-cloud collaboration and edge compression: the edge-cloud collaboration solution is to divide the Transformer model into two parts, one part is deployed on the edge device, and the other part is deployed on the cloud server. The edge device obtains input data to calculate the first half of the model, and transmits the intermediate results to the cloud server to continue the calculation of the subsequent model, and then transmits the results back to the edge device; the edge deployment solution is to use model compression technology to obtain a small Transformer from a large Transformer model, and then deploy it on the edge device. The edge device obtains input data and directly performs reasoning on the small Transformer. However, the edge-cloud collaboration solution requires uploading data to the cloud, which will bring huge communication overhead. The edge compression solution requires a complex model compression algorithm to obtain a lightweight model, and it cannot achieve a balance between reasoning accuracy and reasoning speed. Therefore, it is urgent to design an efficient neural network edge reasoning method to achieve better performance. Summary of the invention
[0004] In view of the problems of high communication overhead and inability to balance inference accuracy and inference speed in current edge deployment methods, the main purpose of the present invention is to propose a Transformer model collaborative inference method for multiple edge devices, which divides the neural network model into multiple sub-models and deploys them on multiple edge devices respectively. Multiple edge devices perform inference in parallel, which reduces the communication overhead of collaborative inference of multiple edge devices while ensuring a slight loss of accuracy, improves the inference speed of edge devices in performing inference tasks, and reduces the inference energy consumption of edge devices in performing inference tasks.
[0005] The main purpose of the present invention is achieved through the following technical solutions:
[0006] The present invention discloses a Transformer model collaborative reasoning method for multiple edge devices, which divides the original data set into multiple sub-data sets with equal numbers of label categories, and then divides the original Transformer model into multiple Transformer sub-models that only retain important structures according to the computing performance and resources of the edge device, helps the sub-model learn the features of the original Transformer model through the sub-task distillation method, and adopts the model integration method to aggregate all Transformer sub-models to improve the overall performance of the integrated model, and deploys the trained Transformer sub-models in the integrated model to the corresponding edge devices respectively. When the edge device receives the reasoning task request, all edge devices execute the reasoning of the Transformer sub-model in parallel, and the intermediate result of the reasoning of each edge device is transmitted to the central node through the network. The central node uses the feature fusion module to fuse all the intermediate results to obtain the final reasoning result, so as to realize the Transformer model collaborative reasoning of multiple edge devices, improve the reasoning speed of the edge device in performing the reasoning task, and reduce the reasoning energy consumption of the edge device in performing the reasoning task.
[0007] The present invention discloses a Transformer model collaborative reasoning method for multiple edge devices, comprising the following steps:
[0008] Step 1: According to the number of edge devices, the original data set is randomly divided into multiple sub-data sets with equal number of label categories;
[0009] When there are N edge devices for deployment, the original data set is represented as Ω0, the number of label categories is C, and the original data set is equally divided into N sub-data sets with the same number of label categories Ω i , i = 1, 2, ..., N. If the number of label categories C is divisible by the number of sub-datasets N, then the sub-dataset Ω i Number of label categories C i is C / N. If it is not divisible, then the sub-dataset Ω i Number of label categories C iExpressed as
[0010]
[0011] Where n = C mod N. Randomly sample C from the original data set in sequence i The data of each category is used to construct a sub-dataset Ω i , and finally obtain N sub-datasets.
[0012] Step 2: Divide the original Transformer model into multiple sub-models based on the computing performance and resources of the edge device, and retain only the most important structure in the original Transformer model to obtain multiple Transformer sub-models that only retain the important structures;
[0013] After obtaining the sub-datasets divided in step 1, the number of layers of the original Transformer model and the dimension of the embedding layer are divided. According to the computing performance and resources of the edge device, the division rate is set to σ%, and for each sub-dataset Ω i , calculate the importance of each self-attention head and hidden layer neural network of the multilayer perceptron in the original Transformer model encoder, and use the change in training loss when removing a self-attention head or hidden layer neuron as the importance indicator. The output feature of a self-attention head h is O h , the importance of self-attention head I h Expressed as
[0014]
[0015] in, represents the training loss.
[0016] When the weight of a neuron in the hidden layer of a multilayer perceptron is w, the importance of the neuron I w Expressed as
[0017]
[0018] According to the importance of self-attention heads and neurons, they are sorted from large to small, and only the parts ranked in the top σ% are retained. The rest are removed, and the connections between models are rebuilt to obtain multiple Transformer sub-models m that only retain important structures. i .
[0019] Step 3: Use the sub-datasets to train the original Transformer model respectively. The Transformer sub-model learns the semantic features of the sub-dataset in the original Transformer model through the sub-task distillation method to improve the prediction accuracy of the Transformer sub-model for the sub-task. That is, the trained Transformer sub-model is obtained through the sub-task distillation method.
[0020] Use N sub-datasets to train the original Transformer model respectively, and obtain N trained original Transformer models {M1, M2, ..., M N}. For any sub-dataset Ω i And the trained original Transformer model M i , using the subtask distillation method from the original Transformer model M i Migrate the corresponding sub-dataset Ω i The knowledge of a specific category in the sub-model m i , improve the prediction accuracy of the Transformer sub-model for sub-dataset samples. Sub-task distillation includes prediction distillation and feature distillation.
[0021] Through predictive distillation, the Transformer sub-model learns the knowledge of the original Transformer model. The original Transformer model is used as the teacher model and the Transformer sub-model is used as the student model. The prediction probability values of the teacher model and the student model are Y t and Y s , using the teacher model’s prediction result as the label y t :
[0022] y t = argmax s Y t (s)
[0023] Among them, s represents all categories in the sub-dataset, and the prediction distillation loss function is expressed as:
[0024]
[0025] Among them, Φ(·) represents the prediction result, y represents the true label, Expressed as a cross entropy loss function:
[0026]
[0027] Feature distillation uses the vectors Q, K, and V in the self-attention module in the original Transformer model as supervision to further learn the deep semantic features of the original Transformer model. Since the dimensions of the vectors Q, K, and V of the original Transformer model and the Transformer sub-model are different, a feature matching module is used to match the dimensions of the two. For any feature X, the matching module FM(·) is expressed as:
[0028] FM(X)=X T X
[0029] The loss function of feature distillation is expressed as:
[0030]
[0031] Among them, when the subscript i of P takes the value of 1, 2, and 3, it represents the vectors Q, K, and V respectively. The subscripts t and s of P represent the original Transformer and the Transformer submodel respectively. i is a hyperparameter used to adjust different loss functions, l is the number of layers of the Transformer sub-model, g(·) is a linear mapping function, and g(k) means mapping the kth layer of the sub-model to the g(k)th layer of the original Transformer model. The mapping function enables the kth layer of the Transformer sub-model to learn the knowledge of the g(k)th layer of the original Transformer model. Expressed as KL divergence loss function:
[0032]
[0033] Therefore, the loss of subtask distillation is expressed as:
[0034]
[0035] Among them, β is a hyperparameter used to adjust different loss functions.
[0036] Step 4: Use the feature fusion module to aggregate multiple Transformer sub-models to obtain an integrated model, and use it to pre-train the original Transformer model on the original dataset to obtain a pre-trained original Transformer model. Use the pre-trained original Transformer model as supervision and use the integrated distillation method to train the integrated model so that the integrated model can learn the rich semantic information in the original Transformer model and improve the prediction accuracy of the integrated model for the original dataset samples;
[0037] After each Transformer sub-model is trained in step 3, the feature fusion module is used to aggregate the intermediate features output by all Transformer sub-models. i The output feature is X i , all features are concatenated according to the column dimension, and then the features are fused through two layers of perceptrons, so the fused feature X fused It is expressed as:
[0038] X fused =FA(X1, X2, ..., X N )=(Concat(X1,X2,...,X N )W1+b1)W2+b2
[0039] Among them, Concat(·) represents the concatenation of features, W1 and W2 represent the weights of the first and second layers of the perceptron, respectively, and b1 and b2 represent the biases of the first and second layers of the perceptron, respectively.
[0040] After the original Transformer model is trained on the original data set, it is used as the teacher model and the integrated model as the student model. Integrated distillation is used to improve the overall performance of the integrated model, which includes two parts: prediction distillation and token distillation. The classification token contains key semantic information. Token distillation uses the classification token of the original Transformer model as supervision. The integrated model learns the rich semantic information in the original Transformer model. Therefore, the loss function of token distillation is expressed as:
[0041]
[0042] Among them, Z1, Z2, ..., Z N Represent the classification tokens of the N sub-models, G represents the mapping matrix, which maps the dimension of the classification token of the integrated model to the dimension of the classification token of the original Transformer model, and Z t represents the original Transformer model classification token, Denotes the mean square error loss function. The prediction distillation is the same as in step 3, so the objective function of the integrated distillation is:
[0043]
[0044] Among them, γ is a hyperparameter used to adjust different loss functions.
[0045] Step 5: Deploy the Transformer sub-models in the integrated model trained in step 4 to the corresponding edge devices, select any edge device as the central node, and deploy the feature fusion module to the central node. When the edge device receives the inference task request, all edge devices execute the inference of the Transformer sub-model in parallel, and the intermediate results of each edge device inference are transmitted to the central node through the network. The central node uses the feature fusion module to fuse all the intermediate results to obtain the final inference result, realizing the collaborative inference of the Transformer model of multiple edge devices, improving the inference speed of edge devices in performing inference tasks, and reducing the inference energy consumption of edge devices in performing inference tasks.
[0046] Beneficial Effects
[0047] 1. The present invention discloses a collaborative reasoning method for a Transformer model for multiple edge devices, which splits the original Transformer model into multiple sub-models and deploys them to multiple edge devices to perform reasoning in parallel, greatly reducing the computational overhead of the model, improving the reasoning speed of edge devices in performing reasoning tasks, and reducing the reasoning energy consumption of edge devices in performing reasoning tasks.
[0048] 2. The present invention discloses a collaborative reasoning method for a Transformer model for multiple edge devices, which uses data set partitioning and model segmentation methods to split the original data set and the original Transformer model into equal numbers of sub-data sets and sub-models, helping the sub-models to retain the key structures in the model, saving redundant computing overhead and reducing computational complexity.
[0049] 3. The present invention discloses a collaborative reasoning method for Transformer models for multiple edge devices. It uses a sub-task distillation method and takes the original Transformer model as supervision to help the sub-model learn the semantic features of the original Transformer model regarding the sub-dataset, thereby significantly improving the prediction accuracy of the sub-model.
[0050] 4. The present invention discloses a Transformer model collaborative reasoning method for multiple edge devices, which uses a feature fusion module to aggregate multiple sub-models to obtain an integrated model, thereby fusing the key features of different sub-models, and adopts an integrated distillation method to improve the prediction accuracy of the integrated model for the original data set samples, improve the overall performance of the integrated model, and achieve a balance between reasoning accuracy and reasoning speed. BRIEF DESCRIPTION OF THE DRAWINGS
[0051] Figure 1 This is a flowchart of a Transformer model collaborative reasoning method for multiple edge devices disclosed in the present invention.
[0052] Figure 2 Schematic diagram of the system framework in an embodiment of the present invention.
[0053] Figure 3 Schematic diagram of the collaborative reasoning process of multiple edge devices in an embodiment of the present invention. DETAILED DESCRIPTION
[0054] The present invention will be described in detail below in conjunction with the accompanying drawings and embodiments, and the technical problems solved by the technical solution of the present invention and the beneficial effects will be discussed. It should be noted that the described embodiments are intended to facilitate the understanding of the present invention and do not have any limiting effect on the present invention.
[0055] Example 1
[0056] The present embodiment discloses an application of a Transformer model collaborative reasoning method for multiple edge devices on a large Transformer model with multiple edge devices. The specific implementation steps are as follows:
[0057] Step 1: Prepare edge devices and original data sets for performing intelligent reasoning tasks, and divide the original data sets into multiple sub-data sets;
[0058] Four edge devices NVIDIA Jetson Nano were selected to collaboratively perform intelligent reasoning tasks. The original dataset was CIFAR-100, which contained a total of 100 categories of sample images. It was equally divided into four sub-datasets according to the number of label categories. Each sub-dataset contained 25 categories of sample images. Afterwards, each sub-dataset randomly adopted 25 categories of sample images from the original dataset and repeated this four times, finally obtaining four sub-datasets with the same number of sample categories.
[0059] Step 2: Select the original Transformer model, split it into multiple sub-models, and remove unimportant self-attention heads and multi-layer perceptron hidden layer neurons;
[0060] DeiT-B is selected as the original Transformer model to be deployed. It is divided into 4 sub-models according to the number of edge devices. The number of layers remains unchanged at 24, and the embedding layer dimension is reduced from 768 to 192. According to the computing performance and hardware resources of the edge device NVIDIA Jetson Nano, the split rate is set to 25%. For each sub-dataset, the importance of the self-attention heads and hidden layer neurons of the multi-layer perceptron in DeiT-B for the sub-dataset category is calculated, and then they are arranged in descending order of importance. The first 25% of the self-attention heads and hidden layer neurons are retained, that is, 3 self-attention heads and 768 hidden layer neurons of the multi-layer perceptron are retained. Finally, the connection between the model structures is re-established to obtain the split sub-models. The structural parameters of the original Transformer model and the split sub-model are shown in the following table:
[0061] Model Number of layers Embedding layer dimensions Hidden layer dimension of multilayer perceptron Number of self-attention heads DeiT-B 12 768 3072 12 Molecular model 12 192 768 3
[0062] Step 3: Use the original Transformer model as supervision and use the sub-task distillation method to train the sub-models separately;
[0063] After training DeiT-B on the four divided sub-datasets, it is used as the teacher model, and the four sub-models are trained separately using the sub-task distillation method. The AdamW optimizer is used to update the model, the number of training iterations is set to 300, the batch size is 128, the initial learning rate is 1e-4, and the learning rate is adjusted according to the cosine annealing algorithm after each iteration until it is 1e-5 at the end. The first-order and second-order momentum coefficients are set to 0.9 and 0.999 respectively. The specific training algorithm is as follows:
[0064]
[0065]
[0066] Step 4: Use the feature fusion module to aggregate all sub-models to obtain an integrated model, and use the integrated distillation method to train the integrated model;
[0067] After obtaining the trained sub-models in step 3, the feature fusion module is used to aggregate all sub-models to obtain an integrated model, and then the integrated distillation method is used to train the integrated model to improve the overall performance of the model. The original dataset CIFAR-100 is used as the training dataset, and the original Transformer model DeiT-B pre-trained on CIFAR-100 is used as the supervision of the integrated model. The AdamW optimizer is used to update the model, the number of training iterations is set to 100, the batch size is 128, the initial learning rate is 5e-5, and the learning rate is adjusted according to the cosine annealing algorithm after each iteration until it is 1e-5 at the end. The first-order and second-order momentum coefficients are set to 0.9 and 0.999 respectively. The specific training algorithm is as follows:
[0068]
[0069] Step 5: Deploy the trained integrated model to multiple edge devices, and the edge devices execute intelligent reasoning tasks in parallel.
[0070] The sub-models in the trained integrated model are deployed to the corresponding edge devices NVIDIA Jetson Nano respectively. One of the NVIDIA Jetson Nano is selected as the central node, and the feature fusion module is deployed to the central node. When performing inference tasks, all edge devices execute the inference of the sub-models in parallel, and the intermediate results of the sub-models are transmitted to the central node through the network. The central node uses the feature fusion module to aggregate all the intermediate results to obtain the final inference result. The CIFAR-100 validation set is used for experimental comparison to measure the average inference accuracy, latency, and energy consumption. The results are as follows:
[0071]
[0072] Among them, "-" indicates that DeiT-B cannot be deployed alone on NVIDIA Jetson Nano due to resource constraints, latency is the average execution time of a single image reasoning task, energy consumption is the average execution energy consumption of a single image reasoning task, and "±" indicates the measurement standard deviation. As can be seen from the above table, large Transformer models cannot be directly deployed on edge devices, while the method disclosed in this embodiment can reduce the number of floating-point operations by 83.19% and the number of parameters by 72.40% with only 1.46% accuracy loss, achieving real-time and low-power reasoning.
[0073] The present invention is compared with the traditional edge compression scheme, that is, the lightweight Transformer models Twins-PCPCT-S and T2T-ViT are obtained by using the model compression algorithm. t -14 was deployed on NVIDIA Jetson Nano to test the inference accuracy, latency and energy consumption. The results are shown in the following table:
[0074]
[0075] As can be seen from the above table, compared with the traditional edge compression scheme Twins-PCPCT-S, the method disclosed in the present invention improves the inference accuracy by 2.72%, while reducing the number of floating-point operations by 51.64%, the inference latency by 28.83% and the inference energy consumption by 18.64%.
[0076] Therefore, the collaborative reasoning method of the Transformer model for multiple edge devices disclosed in the present invention divides a large Transformer model into multiple sub-models, and deploys them to multiple edge devices for parallel reasoning respectively. It uses sub-task distillation and integrated distillation methods to improve the overall performance of the model, significantly reduce the computational overhead of the edge deployment of the Transformer model, and effectively improve the speed at which edge devices execute reasoning tasks, thereby reducing the energy consumption of edge devices in executing reasoning tasks.
[0077] The specific description above further illustrates the purpose, technical solutions and beneficial effects of the invention in detail. It should be understood that the above description is only a specific embodiment of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.
Claims
1. A Transformer model collaborative reasoning method for multiple edge devices, characterized by: The following steps are included: Step 1: According to the number of edge devices, the original data set is randomly divided into multiple sub-data sets with equal number of label categories; Step 2: Divide the original Transformer model into multiple sub-models based on the computing performance and resources of the edge device, and retain only the most important structure in the original Transformer model to obtain multiple Transformer sub-models that only retain the important structures; Step 3: Use the sub-datasets to train the original Transformer model respectively. The Transformer sub-model learns the semantic features of the sub-dataset in the original Transformer model through the sub-task distillation method to improve the prediction accuracy of the Transformer sub-model for the sub-task. That is, the trained Transformer sub-model is obtained through the sub-task distillation method. Step 4: Use the feature fusion module to aggregate multiple Transformer sub-models to obtain an integrated model, and use it to pre-train the original Transformer model on the original dataset to obtain a pre-trained original Transformer model; use the pre-trained original Transformer model as supervision, and use the integrated distillation method to train the integrated model, so that the integrated model learns the rich semantic information in the original Transformer model and improves the prediction accuracy of the integrated model for the original dataset samples; Step 5: Deploy the Transformer sub-models in the integrated model trained in step 4 to the corresponding edge devices respectively, select any edge device as the central node, and deploy the feature fusion module to the central node; When an edge device receives an inference task request, all edge devices execute the reasoning of the Transformer sub-model in parallel. The intermediate results of the reasoning of each edge device are transmitted to the central node through the network. The central node uses the feature fusion module to fuse all the intermediate results to obtain the final reasoning result, thereby realizing the collaborative reasoning of the Transformer model of multiple edge devices, improving the reasoning speed of edge devices in performing reasoning tasks, and reducing the reasoning energy consumption of edge devices in performing reasoning tasks.
2. The Transformer model collaborative reasoning method for multiple edge devices according to claim 1, characterized in that: The implementation method of step one is: When there are N edge devices for deployment, the original data set is represented as Ω0, the number of label categories is C, and the original data set is equally divided into N sub-data sets with the same number of label categories Ω i , i=1,2,…,N; if the number of label categories C can be divided by the number of sub-datasets N, then the sub-dataset Ω i Number of label categories C i is C / N; If it is not divisible, then the sub-dataset Ω i Number of label categories C i Expressed as Where n = C mod N; randomly sample C from the original data set in sequence i The data of each category is used to construct a sub-dataset Ω i , and finally N sub-datasets are obtained.
3. A Transformer model collaborative reasoning method for multiple edge devices as claimed in claim 2, characterized in that: The implementation method of step 2 is: After obtaining the sub-datasets divided in step 1, the number of layers of the original Transformer model and the dimension of the embedding layer are divided; according to the computing performance and resources of the edge device, the division rate is set to σ%, and for each sub-dataset Ω i , calculate the importance of each self-attention head and hidden layer neural network of the multilayer perceptron in the original Transformer model encoder, and use the change in training loss when removing a self-attention head or hidden layer neuron as the importance indicator. The output feature of a self-attention head h is O h ,Self-attention head importance I h Expressed as in, represents the training loss; When the weight of a neuron in the hidden layer of a multilayer perceptron is w, the importance of the neuron Iw is expressed as According to the importance of self-attention heads and neurons, they are sorted from large to small, and only the parts ranked in the top σ% are retained. The rest are removed, and the connections between models are rebuilt to obtain multiple Transformer sub-models m that only retain important structures. i .
4. The Transformer model collaborative reasoning method for multiple edge devices as claimed in claim 3, characterized in that: The implementation method of step three is: Use N sub-datasets to train the original Transformer model respectively, and obtain N trained original Transformer models {M1,M2,…,M N }; For any sub-dataset Ω i And the trained original Transformer model M i , using the subtask distillation method from the original Transformer model M i Migrate the corresponding sub-dataset Ω i The knowledge of a specific category in the sub-model m i , improve the prediction accuracy of the Transformer sub-model for sub-dataset samples; sub-task distillation includes prediction distillation and feature distillation; Through predictive distillation, the Transformer sub-model learns the knowledge of the original Transformer model. The original Transformer model is used as the teacher model and the Transformer sub-model is used as the student model. The prediction probability values of the teacher model and the student model are Y t and Y s , using the prediction result of the teacher model as the label y t : and t =arg max s AND t (s) Among them, s represents all categories in the sub-dataset, and the prediction distillation loss function is expressed as: Among them, Φ(·) represents the prediction result, y represents the true label, Expressed as a cross entropy loss function: Feature distillation uses the vectors Q, K, and V in the self-attention module in the original Transformer model as supervision to further learn the deep semantic features of the original Transformer model. Since the dimensions of the vectors Q, K, and V of the original Transformer model and the Transformer sub-model are different, a feature matching module is used to match the dimensions of the two. For any feature X, the matching module FM(·) is expressed as: FM(X)=X T X The loss function of feature distillation is expressed as: Among them, when the subscript i of P takes the value of 1, 2 and 3, it represents the vectors Q, K and V respectively, and the subscripts t and s of P represent the original Transformer and Transformer submodel respectively. i is a hyperparameter used to adjust different loss functions, l is the number of layers of the Transformer sub-model, g(·) is a linear mapping function, g(k) means mapping the k-th layer of the sub-model to the g(k)-th layer of the original Transformer model. Through the mapping function, the k-th layer of the Transformer sub-model learns the knowledge of the g(k)-th layer of the original Transformer model. Expressed as KL divergence loss function: Therefore, the loss of subtask distillation is expressed as: Among them, β is a hyperparameter used to adjust different loss functions.
5. The Transformer model collaborative reasoning method for multiple edge devices according to claim 4, characterized in that: Step 4 is implemented as follows: After each Transformer sub-model is trained in step 3, the feature fusion module is used to aggregate the intermediate features output by all Transformer sub-models. i The output feature is X i , all features are concatenated according to the column dimension, and then fused through two layers of perceptrons, so the fused feature X fused It is expressed as: X fused =FA(X1,X2,…,X N )=(Concat(X1,X2,…,X N )W1+b1)W2+b2 Among them, Concat(·) represents the concatenation of features, W1 and W2 represent the weights of the first and second layers of the perceptron, respectively, and b1 and b2 represent the biases of the first and second layers of the perceptron, respectively; After the original Transformer model is trained on the original data set, it is used as the teacher model and the integrated model as the student model. Integrated distillation is used to improve the overall performance of the integrated model, which includes two parts: prediction distillation and token distillation. The classification token contains key semantic information. Token distillation uses the classification token of the original Transformer model as supervision. The integrated model learns the rich semantic information in the original Transformer model. Therefore, the loss function of token distillation is expressed as: Among them, Z1, Z2, …, Z N Represent the classification tokens of the N sub-models, G represents the mapping matrix, which maps the dimension of the classification token of the integrated model to the dimension of the classification token of the original Transformer model, and Z t represents the original Transformer model classification token, represents the mean square error loss function; the prediction distillation is the same as in step 3, so the objective function of the integrated distillation is: Among them, γ is a hyperparameter used to adjust different loss functions.
Citation Information
Cited By
Server data processing method based on deep learning model
CN119311422A
A server data processing method based on deep learning model
CN119311422B
Basic model-oriented scene adaptive edge cloud collaborative inference system and method
CN119721238A
Edge computing power network resource dynamic scheduling system based on IPv6 protocol enhancement
CN121262169A
Edge-end collaborative reasoning method and system based on large model characteristics and dynamic network
CN121581206A
