Inference acceleration method and device based on cooperative meta-learning

CN116484839BActive Publication Date: 2026-10-09INSTITUTE OF INFORMATION ENGINEERING CHINESE ACADEMY OF SCIENCES
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202310312448.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-03-28
Publication Date
2026-10-09
Estimated Expiration
2043-03-28

AI Technical Summary

Technical Problem

[0010]已有的早退方法虽然简单高效,但仍然存在两个缺陷:(1)现有早退模型更多地关注于简单样本的推理加速,而困难样本依然无法在浅层处理,最终还是要诉诸最后一层进行输出

Benefits of technology

[0036] 1. This invention proposes a collaborative meta-learning training method that can significantly reduce the computational cost of the model and improve the inference speed of the model with minimal performance loss.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116484839B_ABST
    Figure CN116484839B_ABST
Patent Text Reader

Abstract

The application discloses a reasoning acceleration method and device based on cooperative meta-learning. The method comprises the following steps: constructing a reasoning model; wherein the reasoning model is a transformer-based model with an early exit classifier added after each transformer layer; training the reasoning model; wherein the training of the reasoning model comprises the following steps: optimizing initial parameters of the reasoning model, and inputting the optimized parameters into an Adam optimizer for gradient update to train the early exit classifier; using the trained reasoning model to perform task prediction, and outputting a prediction result of the task based on an entropy-based exit mechanism. The application can improve the reasoning speed of a model while keeping a very small performance loss.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of artificial intelligence technology, specifically relating to a reasoning acceleration method and apparatus based on collaborative meta-learning. Background Technology

[0002] Since the introduction of the Transformer architecture in 2017 (Vaswani et al., 2017), numerous models based on the Transformer architecture have emerged and, due to their superior performance, have been widely applied to various natural language processing tasks. A significant milestone was the introduction of the BERT model (bi-directional encoder representations from transformers) in 2018 (Devlin et al., 2019). At that time, BERT achieved state-of-the-art results in 11 natural language processing tasks, ushering in the era of pre-training plus fine-tuning paradigms in the field of natural language processing. While the BERT series of models (Yang et al., 2019; Liu et al., 2019; Lan et al., 2020) possess powerful advantages, their inference speed is very slow. In real-world scenarios, this slow inference speed hinders efficient model deployment, which becomes even more difficult when deployed on edge devices.

[0003] To address these issues, research focusing on improving the inference efficiency of Transformer models has emerged in large numbers. For example, in static model compression, existing techniques include (Hinton et al., 2015; Sanh et al., 2020; Sun et al., 2019; Jiao et al., 2020; Sun et al., 2020) knowledge distillation, (Voita et al., 2019; Wang et al., 2020; Sajjad et al., 2023) pruning, (Zhuang et al., 2019; Shen et al., 2020; Gao et al., 2021) quantization, (Xu et al., 2020) module replacement, and (Fan et al., 2022) layer dropping. While these methods can improve inference efficiency to some extent, such static compression methods permanently remove certain components of the model, leading to a sharp decline in model performance. Furthermore, the structure of these models cannot be dynamically adjusted according to different hardware because they are already compressed before deployment. Due to the problems of the static compression models mentioned above, conditional computation (Bengio et al., 2013; Davis et al., 2014; Graves, 2017) was proposed and became a key technology for dynamic inference models. Among them, the early-retreat method (Zhou et al., 2020; Kaya et al., 2019; Xin et al., 2020; Zhu et al., 2021; Liu et al., 2020; Xin et al., 2021) is a representative method of conditional computation and has been widely studied due to its simplicity and efficiency. Models employing the early-retreat idea can identify the complexity of samples and dynamically determine which layer of the Transformer to output at, rather than outputting a prediction only at the last layer. During fine-tuning, the early-retreat classifier added after each BERT Transformer block is trained first. During inference, the early-retreat classifier at an intermediate layer dynamically outputs a prediction. In the BERT series of early-retreat models, three main training methods are included: joint training, two-stage training, and alternating training.

[0004] (I) Joint Training

[0005] The core idea of ​​joint training is to transfer the early termination classifier c1 to c 12The cross-entropy loss is weighted and summed, and all classifiers participate in training together. PABEE, proposed by Zhou et al. (2020), employs a joint training method, weighting and summing the losses of each early-leaving classifier before averaging them, thus involving all classifiers in training. Furthermore, PABEE introduces the patience metric for early withdrawal. The GAML-BERT model, proposed by Zhu et al. (2021), also uses joint training, summing the losses of all early-leaving classifiers using the same weighting method. In addition, GAML-BERT utilizes mutual learning knowledge distillation and gradient alignment to improve classifier performance. The LeeBERT model, proposed by Zhu (2021), trains each early-leaving classifier using joint training, but instead of using weights, it directly sums the losses of each classifier. Significantly different from the previous methods, LeeBERT breaks away from the notion of only learning the last layer, allowing each classifier to learn from each other, and also proposes a cross-layer optimization algorithm to optimize the results.

[0006] (II) Two-stage training

[0007] The core idea of ​​two-stage training is to fine-tune the classifier c of the last layer in the first stage. 12 In the second stage, we will fine-tune c1 to c2 together. 11 Xin et al. (2020) proposed the DeeBERT model, an early attempt to apply the early termination concept to natural language processing. Its training method employs a two-stage approach: first, consistent with general fine-tuning, the last classifier layer is fine-tuned; then, the parameters from the first stage are frozen, and the remaining early termination classifiers are fine-tuned. Entropy is used for the exit decision, calculating the entropy predicted by each classifier. Liu et al. (2020) proposed FastBERT, which explores a self-distillation method to improve the classification ability of early termination classifiers. Its training method first fine-tunes the last classifier layer, then distills the remaining branch classifiers. FastBERT proposes using an uncertainty index to determine whether the inference results of the branch classifiers are sufficiently confident.

[0008] (III) Alternating Training

[0009] The core idea of ​​alternating training is to combine the two methods mentioned above, using two-stage training in odd rounds and joint training in even rounds. (Xin et al., 2021) proposed the BERxiT model, which integrates existing joint training and two-stage training. The main idea is to use the two training methods alternately, that is, two-stage training in odd rounds and joint training in even rounds. In addition, BERxiT can be applied not only to classification tasks but also to regression tasks.

[0010] While existing early-out methods are simple and efficient, they still have two drawbacks: (1) Existing early-out models focus more on accelerating inference for simple samples, while difficult samples still cannot be processed in shallow layers and ultimately still require the final layer for output. (2) As the length of the input sequence increases, the computational cost of the model increases proportionally. Although existing early-out methods can output dynamically, the classifiers of these dynamic inference models are not sufficiently trained, resulting in an inability to better learn the semantic features of the samples. Specifically, such as Figure 1 As shown, the three existing mainstream training methods—joint training, two-stage training, and alternating training—each have their drawbacks. Joint training results in poor overall performance of premature classifiers, with some classifiers being stronger than others, and weaker classifiers tending to drag down the performance of stronger ones. Two-stage training maintains strong performance in the final layer classifier but fails to guarantee the performance of shallower classifiers because the second stage freezes relevant parameters. Alternating training combines the advantages of the first two methods but cannot avoid their drawbacks, and it is also more complex to operate and less efficient to deploy. Summary of the Invention

[0011] To address the aforementioned issues, this invention proposes a reasoning acceleration method and apparatus based on collaborative meta-learning, which can improve the reasoning speed of the model.

[0012] The technical content of this invention includes:

[0013] A method for accelerating inference based on collaborative meta-learning, characterized in that the method includes:

[0014] Construct an inference model; wherein the inference model is a transformer-based model with an additional early termination classifier added after each transformer layer;

[0015] Training an inference model; wherein, training the inference model includes: optimizing the initial parameters of the inference model, and feeding the optimized parameters into the Adam optimizer for gradient update, so as to train the early termination classifier;

[0016] The trained inference model is used to predict the task, and the prediction results of the task are output based on an entropy-based exit mechanism.

[0017] Furthermore, the transformer-based model includes: BERT model, ALBERT model, or RoBERTa model.

[0018] Furthermore, the initial parameters of the optimized inference model include:

[0019] Obtain the meta-training task distribution and meta-learning hyperparameters;

[0020] Extracting meta-training tasks from the meta-training task distribution Where i represents the sequence number of the meta-training task;

[0021] Calculate each training task Adaptive parameters Where θ represents the initial parameters of the inference model, and α represents the step size. Represents the gradient. f represents loss. θ It is a function of the initial parameter θ;

[0022] Obtain optimization parameters Where β represents the element step size.

[0023] Further, the task is a text classification task; the step of feeding the optimization parameters into the Adam optimizer for gradient update to train the early termination classifier includes:

[0024] During the fine-tuning phase, all early termination classifiers are jointly trained using the Adam optimizer; specifically, in each training round, the cross-entropy loss is based on each early termination classifier. Total loss for updating the inference model Where j represents the index of the early termination classifier, and L represents the number of transformer layers;

[0025] After fine-tuning to the specified number of rounds, the reasoning model is obtained.

[0026] Furthermore, the task is a regression task; the step of feeding the optimization parameters into the Adam optimizer for gradient update to train the early termination classifier includes:

[0027] In each round of training during the fine-tuning phase, the mean squared error loss is based on each early termination classifier. Total loss for updating the inference model Where j represents the index of the early termination classifier, and L represents the number of transformer layers;

[0028] After fine-tuning to the specified number of rounds, the reasoning model is obtained.

[0029] Further, the device includes:

[0030] A building module is used to build an inference model; wherein, the inference model is a transformer-based model with an additional early termination classifier added after each transformer layer;

[0031] The training module is used to train the inference model; wherein, training the inference model includes: optimizing the initial parameters of the inference model, and feeding the optimized parameters into the Adam optimizer for gradient update in order to train the early termination classifier;

[0032] The prediction module is used to perform task prediction using the trained inference model and output the prediction results of the task based on an entropy-based exit mechanism.

[0033] An electronic device, characterized in that the electronic device comprises: a processor and a memory storing computer program instructions; the processor implements any of the methods described above when executing the computer program instructions.

[0034] A computer-readable storage medium, characterized in that the computer-readable storage medium stores computer program instructions, which, when executed by a processor, implement any of the methods described above.

[0035] Compared with the prior art, the present invention has at least the following advantages:

[0036] 1. This invention proposes a collaborative meta-learning training method that can significantly reduce the computational cost of the model and improve the inference speed of the model with minimal performance loss.

[0037] 2. Unlike previous work, the model proposed in this invention combines all available language information for prediction and approximates features on new tasks that were originally inaccessible through meta-learning.

[0038] 3. Numerous experimental results also demonstrate that the proposed model can provide an effective balance between model performance and inference efficiency. Attached Figure Description

[0039] Figure 1 Three main training methods for early termination models and their drawbacks.

[0040] Figure 2 The method flowchart of the present invention.

[0041] Figure 3 Flowchart of Algorithm 1.

[0042] Figure 4 Flowchart of Algorithm 2.

[0043] Figure 5 Line graph comparison results of four training methods. Detailed Implementation

[0044] The technical solution of the present invention will be clearly and completely described below with reference to the embodiments and accompanying drawings. It should be understood that the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0045] The collaborative meta-learning inference acceleration method proposed in this invention is another highly competitive approach following joint training, two-stage training, and alternating training, and can be used to solve many problems existing in current training methods. Meta-learning has many applications (Finn et al., 2017; Liu et al., 2022; Baydin et al., 2022; Andrychowicz et al., 2016), and this method mainly focuses on optimizing initialization parameters through meta-learning (Finn et al., 2017). Specifically, it is no longer the case that only one or a few layers of a shallow classifier are effective; in the training of the classifier, this invention considers all layers for sufficient training from the beginning. Furthermore, semantic features embedded in deep layers are deeply extracted, and features from new tasks that were originally inaccessible can also be approximated by this invention for future predictions. At this point, shallow and deep knowledge are effectively integrated, enabling relatively accurate predictions for different downstream tasks. In summary, after sufficient training through meta-learning, the early-retreat classifier learns not just a result, but the ability to extract semantic features from samples. This ability to "learn to learn" enables the method to obtain a set of optimized initialization parameters. These parameters require only a small number of gradient updates, which is the key to the method's rapid adaptation to new tasks.

[0046] Specifically, the inference acceleration method based on collaborative meta-learning of the present invention, such as... Figure 2 As shown, it includes the following steps.

[0047] Step 1: Construct the inference model.

[0048] In the original BERT architecture, there is only one classifier, which is placed at the end of the Transformer layer. The backbone model and the classifier are updated together on downstream tasks. This classifier is a fully connected neural network that takes the hidden state h of the last layer as input and outputs a prediction. To implement the idea of ​​early termination, this method adds an extra classifier after each Transformer layer. For the BERT-base model, which has twelve Transformer layers, there are twelve classifiers. Each early termination classifier can provide its own prediction, providing a prerequisite for the model to terminate early during the inference phase. Specifically, this method uses BERT-base as the backbone model (besides BERT, this invention also applies to other transformer-based models, such as ALBERT, RoBERTa, etc.), and adds corresponding early termination classifiers. First, the [CLS] token corresponding to the i-th hidden layer state is represented as:

[0049] h i =f i(x;Ω1,Ω2,Ω3,…,Ω i (1)

[0050] Where x is the input sequence, Ω i f is the parameter of the i-th Transformer layer in BERT. i It is a mapping from the input to the state of the i-th hidden layer.

[0051] Step 2: Train the inference model.

[0052] (Jawahar et al., 2019) provided an in-depth analysis of the BERT model structure, indicating that BERT's shallow layers learn surface features, intermediate layers learn syntactic features, and deep layers learn semantic features. To improve the representational ability of the early-retreat classifier and make it applicable to different natural language processing tasks, this invention proposes a collaborative meta-learning training method. This method is based on Algorithm 1 and Algorithm 2, and... Figure 3 and Figure 4 This reveals the relevant details of the meta-learning part and the training process.

[0053] Algorithm 1: Meta-learning method of this invention

[0054]

[0055]

[0056] Algorithm 2: Training process of the present invention (MetaBERT)

[0057]

[0058] In form, this invention first considers the existence of a model, which is parameterized by a set of functions f. θ The parameters of the model are represented by θ. For a new task... The model's parameter θ becomes θ′ i Vector θ′ i In the mission The above is obtained from one or more gradient updates:

[0059]

[0060] Where α is the step size. The symbol represents the gradient. The symbol f represents loss. θ It is a function of θ.

[0061] The training of model parameters is achieved through optimization. This is achieved through the performance of θ, where θ takes into account the influence of... Cross-task sampling. At this point, the meta-objective becomes:

[0062]

[0063] Here, the meta-optimization is performed on the model parameters θ, while the objective is calculated using the updated model parameters θ′.

[0064] Cross-task meta-optimization is performed via stochastic gradient descent, and the model parameters θ are updated in the following form:

[0065]

[0066] Where β is the step size.

[0067] The optimized model parameters θ are derived from Algorithm 1. These parameters are then fed into the Adam optimizer to train the early termination classifiers. Specifically, the loss of the early termination classifier for each Transformer layer can be expressed as follows:

[0068]

[0069] Where x is the input sequence, y is its corresponding label, and c i w is the classifier for the i-th exit layer. i It corresponds to c i The parameter M is a loss function specific to a certain task (since this example is for text classification, cross-entropy loss is used. This invention is also applicable to other tasks, such as regression tasks, in which case mean squared error is used as the loss function).

[0070] Step 3: Use the trained inference model to predict the task and output the prediction result of the task based on the entropy exit mechanism.

[0071] Regarding the exit decision, this method is consistent with (Xin et al., 2020), employing an entropy-based exit mechanism. Specifically, the output distribution P of the classifier in the i-th exit layer... i The entropy, as the prediction confidence level Entr:

[0072] Entr = entropy(P i (6)

[0073] Once the confidence level Entr falls below a specific threshold γ, the inference process stops, and the prediction is output prematurely. The hyperparameter γ can be adjusted according to the required speedup.

[0074] Experimental data.

[0075] The following section introduces the dataset, evaluation metrics, comparison algorithms, and implementation details used in the MetaBERT experiments, and presents the experimental results and analysis.

[0076] (1) The first part introduces the dataset and evaluation metrics. (Wang et al., 2018) The GLUE (General Language Understanding Evaluation) benchmark dataset is a recognized important benchmark in the field of natural language processing. The GLUE dataset contains different types of tasks. This invention mainly selects seven tasks to verify the proposed method. The tasks in GLUE include paraphrasing similarity matching (PSM), sentiment classification (SC), natural language inference (NLI), and language acceptability. As shown in Table 1, the detailed information of the selected tasks is shown in the table. Except for the MRPC task, which uses the average of accuracy and F1 score, the other tasks use accuracy as the evaluation metric.

[0077] Table 1 Introduction to the GLUE Benchmark Dataset

[0078] QQP 363,849 40,430 390,965 MNLI 392,702 9,815 9,796 QNLI 104,743 5,463 5,463 SST-2 67,349 872 1,821 MRPC 3,668 408 1,725 RTE 2,490 277 3,000 CoLA 8,551 1,043 1,063

[0079] For the PSM task, this invention employs Quora Question Pairs (QQP) and (Dolan et al., 2005) Microsoft Research Paragraph Corpus (MRPC), both of which aim to determine whether two sentences in a question are semantically identical.

[0080] For the Sentence Treebank (SC) task, this invention selects the Stanford Sentiment Treebank (SST-2) task (Socher et al., 2013). The goal of this task is to have the model predict the sentiment expressed in a given sentence.

[0081] Table 2 Comparison results of MetaBERT with other static and dynamic models

[0082]

[0083] For the NLI task, this invention conducts experiments on three tasks: Multi-Type Natural Language Inference (MNLI) (Williams et al., 2018), Question Answering Natural Language Inference (QNLI) (Rajpurkar et al., 2016), and Real-Time Entailment (RTE). MNLI uses a corpus of sentence pairs extracted from multiple domains to evaluate the model's generality. QNLI is a dataset derived from the question-answering dataset SQuAD, and its purpose is to predict whether the context sentence contains the answer to the question. RTE is based on a series of textual entailment challenges from the General Language Understanding Evaluation (GLUE).

[0084] For the Linguistic Acceptability task, this invention employs the Corpus of Linguistic Acceptability (CoLA) (Warstadt et al., 2019), a binary classification task that, given a sentence, determines whether it is grammatically correct.

[0085] (2) Next is the comparison of algorithms. Besides the basic backbone model, this invention mainly compares with two models. One is a static model, including BERT-6L, DistillBERT, LayerDrop, BERT-PKD, and BERT-of-Theseus. The other is a dynamic model, including GAML-BERT, Shallow-Deep, FastBERT, DeeBERT, and PABEE. BERT-6L indicates that the first 6 layers of the BERT model are selected as the lower bound among all compared algorithms. The DistillBERT model mainly uses knowledge distillation technology to reduce the size of the originally complex and bloated BERT model, minimizing its size as much as possible without significantly reducing performance. LayerDrop is similar to dropout, mainly using a dropout rule to shrink the model. This dropout rule includes: dropping one layer every few layers, searching for combinations of layer dropouts, and modeling the dropout itself as a task to learn and optimize. BERT-PKD explores different ways of knowledge distillation: one is learning the last layer of the teacher network, and the other is learning from the middle layers of BERT. The main idea of ​​BERT-of-Theseus is to gradually replace modules in BERT with smaller modules. This compression idea is similar to knowledge distillation, and it only requires a task-specific loss function, making it a general compression method. GAML-BERT is a dynamic early-retreat model that utilizes mutual learning and gradient alignment. Each early-retreat classifier can learn from each other, effectively avoiding potential conflicts between distillation loss and cross-entropy loss. The Shallow-Deep model, originally used in computer vision, makes predictions through intermediate layers instead of waiting until the last layer. The number of layers required for prediction varies depending on the difficulty of the sample; simple samples only require the first few layers, while difficult samples require more layers for accurate prediction. FastBERT, originally developed for Chinese datasets, uses self-distillation, treating the last layer as the teacher and the remaining layers as students, allowing all student classifiers to learn from the teacher classifier in the last layer. DeeBERT is a two-stage training model. The first stage is consistent with general fine-tuning; the second stage freezes the parameters from the first stage and fine-tunes the remaining classifiers, outputting predictions in advance based on entropy. PABEE overcomes the problems of entropy-based exit mechanisms by designing a patience-based exit mechanism that can robustly output results. In addition, a joint training method is used to train the early exit classifier.

[0086] Table 3 Comparison results between different training methods

[0087]

[0088] (3) Next, we will discuss the implementation details. The environment used in this invention is an NVIDIA GPU, model V100, with 16GB of video memory. Regarding the specific parameter settings, they are consistent with (Xin et al., 2020), with the batch size for fine-tuning set to 32, and the batch size for the inference stage of both this method and its comparison algorithm set to 1. The model proposed in this invention is optimized using the Adam optimizer, with a learning rate set to 2e-5. For the hyperparameter settings of the meta-learning algorithm, this invention is consistent with (Finn et al., 2017). For the number of training epochs and the threshold γ, this invention is consistent with (Xin et al., 2020).

[0089] (4) Finally, the experimental results and analysis are presented. First, the overall performance is analyzed. To demonstrate the effectiveness of this invention, the proposed model is compared with state-of-the-art methods. All results are shown in Tables 2 and 3. Overall, this method achieves better results than state-of-the-art methods on most tasks. The success of the proposed model is mainly attributed to the collaborative meta-learning training method. Unlike previous methods, this method considers linguistic information embedded in all layers, thus producing more accurate results.

[0090] To verify the robustness and efficiency of MetaBERT, our method was first compared with mainstream static and dynamic models. As shown in Table 2, MetaBERT achieved the best results among all static and dynamic models. This demonstrates that our method addresses the problem of premature classifiers lacking semantic knowledge, and through the concept of meta-learning, achieves an effective balance between inference results and inference efficiency.

[0091] To further reveal the performance of the proposed method, such as Figure 5 As shown in Table 3, this invention is compared with three other mainstream training methods: Joint Training, Two-Stage Training, Alternating Training, and our method (MetaBERT). The comparison results are presented in Table 3. As Table 3 shows, our method, MetaBERT, outperforms the other three training methods across all selected tasks. Among these four training methods, the Joint Training method performs the worst, due to its indiscriminate treatment of all premature classifiers, resulting in poor overall performance. The Two-Stage Training method achieves relatively good performance, but it is still weaker than our method. Its disadvantages lie in sacrificing the performance of shallow classifiers to improve the performance of the last classifier. Furthermore, it is not efficient enough, requiring two stages to complete the classifier training. As for the Alternating Training method, although it combines the advantages of Joint Training and Two-Stage Training, it still cannot achieve the best performance among all training methods.

[0092] from Figure 5 As can be seen, MetaBERT significantly outperforms the other three training methods. Specifically, the key to MetaBERT's performance improvement lies in its use of co-learning to simulate features on novel, previously inaccessible tasks. These findings fully validate that embedding deep, high-level semantic features within the training framework of this method can significantly enhance model performance.

[0093] In summary, this invention represents a fourth competitive training method following the current mainstream methods—joint training, two-stage training, and alternating training—effectively addressing the problems inherent in the first three methods. In short, joint training methods suffer from low overall performance, with weak classifiers easily dragging down the performance of strong classifiers; two-stage training methods, by freezing parameters, result in better performance for the final layer but poor performance for shallow classifiers; alternating training methods struggle to avoid the drawbacks of joint and two-stage training methods, and are also inefficient to deploy. To address these issues, this invention offers a collaborative meta-learning training method, completely overcoming the problems of low overall performance, poor performance of shallow classifiers, and inefficient deployment. In terms of advantages, this invention effectively combines language information embedded in all early-retreat classifiers; and through meta-learning, it learns features from new tasks that were previously inaccessible; experimentally, compared to state-of-the-art models, it achieves optimal performance and a better balance between model performance and inference efficiency.

[0094] It will be apparent to those skilled in the art that the present invention is not limited to the details of the exemplary examples described above, and that the invention can be implemented in other specific forms without departing from its spirit or essential characteristics. Therefore, the examples should be considered exemplary and non-limiting in all respects, and the scope of the invention is defined by the appended claims rather than the foregoing description. Thus, all variations falling within the meaning and scope of equivalents of the claims are intended to be included within the present invention, and no reference numerals in the claims should be construed as limiting the scope of the claims.

Claims

1. A reasoning acceleration method based on collaborative meta-learning, characterized in that, The method includes: Construct an inference model; wherein the inference model is a transformer-based model with an additional early termination classifier added after each transformer layer; Training an inference model; wherein, training the inference model includes: optimizing the initial parameters of the inference model, and feeding the optimized parameters into the Adam optimizer for gradient update, so as to train the early termination classifier; The trained inference model is used to predict the task, and the prediction result of the task is output based on the entropy exit mechanism. The initial parameters of the optimized inference model include: Obtain the meta-training task distribution and meta-learning hyperparameters; Extracting meta-training tasks from the meta-training task distribution ;in, Indicates the sequence number of the meta-training task; Calculate each training task Adaptive parameters ;in, Represents the initial parameters of the inference model. Indicates step size, Represents the gradient. Indicates loss, It's about the initial parameters. The function; Obtain optimization parameters ;in, Indicates the step size; The task is a text classification task; the step of feeding the optimization parameters into the Adam optimizer for gradient update to train the early termination classifier includes: During the fine-tuning phase, all early termination classifiers are jointly trained using the Adam optimizer; specifically, in each training round, the cross-entropy loss is based on each early termination classifier. The total loss of updating the inference model ;in, Indicates the sequence number of the early termination classifier. Indicates the number of layers in the transformer layer; After fine-tuning to the specified number of rounds, the reasoning model is obtained.

2. The method as described in claim 1, characterized in that, The transformer-based models include: BERT model, ALBERT model, or RoBERTa model.

3. A reasoning acceleration device based on collaborative meta-learning, characterized in that, The device includes: A building module is used to build an inference model; wherein, the inference model is a transformer-based model with an additional early termination classifier added after each transformer layer; The training module is used to train the inference model; wherein, training the inference model includes: optimizing the initial parameters of the inference model, and feeding the optimized parameters into the Adam optimizer for gradient update in order to train the early termination classifier; The prediction module is used to perform task prediction using the trained inference model and output the prediction results of the task based on an entropy-based exit mechanism. The initial parameters of the optimized inference model include: Obtain the meta-training task distribution and meta-learning hyperparameters; Extracting meta-training tasks from the meta-training task distribution ;in, Indicates the sequence number of the meta-training task; Calculate each training task Adaptive parameters ;in, Represents the initial parameters of the inference model. Indicates step size, Represents the gradient. Indicates loss, It's about the initial parameters. The function; Obtain optimization parameters ;in, Indicates the step size; The task is a text classification task; the step of feeding the optimization parameters into the Adam optimizer for gradient update to train the early termination classifier includes: During the fine-tuning phase, all early termination classifiers are jointly trained using the Adam optimizer; specifically, in each training round, the cross-entropy loss is based on each early termination classifier. The total loss of updating the inference model ;in, Indicates the sequence number of the early termination classifier. Indicates the number of layers in the transformer layer; After fine-tuning to the specified number of rounds, the reasoning model is obtained.

4. An electronic device, characterized in that, The electronic device includes: a processor and a memory storing computer program instructions; the processor, when executing the computer program instructions, implements the method as described in any one of claims 1-2.

5. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer program instructions that, when executed by a processor, implement the method as described in any one of claims 1-2.

Citation Information

Patent Citations

  • Comparative self-distillation BERT acceleration method and device based on check alignment reasoning

    CN116663532A