{'fraction_non_alphanumeric': 0.03392828429007879, 'fraction_numerical': 0.014364581658358792, 'mean_word_length': 4.926937738246505, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Efficient Fine-Tuning of Compressed Language Models with Learners

Fine-tuning BERT-based models is resource-intensive in memory, computation, and time. While many prior works aim to improve inference efficiency via compression techniques, e.g., pruning, these works do not explicitly address the computational challenges of training to downstream tasks. We introduce Learner modules and priming, novel methods for fine-tuning that exploit the overparameterization of pre-trained language models to gain benefits in convergence speed and resource utilization. Learner modules navigate the double bind of 1) training efficiently by fine-tuning a subset of parameters, and 2) training effectively by ensuring quick convergence and high metric scores. Our results on DistilBERT demonstrate that learners perform on par with or surpass the baselines. Learners train 7x fewer parameters than state-of-the-art methods on GLUE. On CoLA, learners fine-tune 20% faster, and have significantly lower resource utilization.


Introduction
Transformer-based Pre-trained Language Models (PLM) have become ubiquitous in Natural Language Processing (NLP). BERT and its various derivatives outperform the previous generations of NLP models significantly, requiring in contrast many more parameters and, consequently, more powerful hardware resources for training and inference (Strubell et al., 2019;Schwartz et al., 2020;Devlin et al., 2019). Works in model compression have sought to improve inference efficiency of these models by pruning, quantization, and distillation (Ganesh et al., 2021;Dhar et al., 2021). Fine-tuning is, however, complicated by the size of PLMs (Strubell et al., 2019;Schwartz et al., 2020). For example, BERT and DistilBERT have parameter counts of 110 million and 66 million parameters respectively (Devlin et al., 2019;Sanh et al., 2019). Fine-tuning such large models requires substantial data and considerably more computations and memory accesses than inference (Cai et al., 2020;Schwartz et al., 2020;Strubell et al., 2019). Further, memory operations are energy intensive and slow (Han et al., 2016;Hennessy & Patterson, 2012). Fine-tuning must be made fast and resource-efficient to facilitate use-cases such as personalized auto-correct systems on mobile device keyboards, or green AI (Hard et al., 2018;Dhar et al., 2021;Schwartz et al., 2020).
Prior works in efficient training focus primarily on parameter efficiency for uncompressed (i.e., huge) transformerbased models (Zaken et al., 2021;Houlsby et al., 2019;He et al., 2022;Guo et al., 2021). Adapters (Houlsby et al., 2019) manage to achieve parameter efficiency in a computationally efficient manner, while difference pruning (Guo et al., 2021) requires triple the training-time parameter usage. We show that the computational efficiency of adapters is undermined on a compressed model by slow convergence. State-of-the-art methods in efficient fine-tuning, namely Freeze-and-Reconfigure (FAR), are decidedly quick to converge, but require a far greater proportion of parameters and are plagued by slow memory operations (Vucetic et al., 2022). The optimal efficient fine-tuning technique must then satisfy a few requirements: 1) demonstrate quick convergence, and 2) be resource efficient in memory, computation, and time.
Our main contribution is the proposal of Learner modules fine-tuned with priming steps, which satisfy these requirements by: a) exploiting pre-trained parameters for their quick convergence, b) exploiting model overparameterization to train a small subset of parameters, and c) avoiding slow, complex memory operations. Learner modules, as illustrated in Figure 1, are added in parallel to each linear layer in a target model. Learners consist of a low-rank projection matrix whose product with module input is added to the output of the linear layer. In essence, the small learner module learns for the much larger linear layer. After training, the learner modules can be collapsed leaving just the original model, unlike adapters which permanently add modules to the architecture. In this work we demonstrate the arXiv:2208.02070v1 [cs.CL] 3 Aug 2022  Figure 1. Comparison of learner modules against other architectures. Grey indicates a frozen (i.e., not trained) component, green indicates trained components. Our proposed modules, learners, are shown in a) where a linear layer is frozen except for the bias and the two projection matrices, P1andP2, are trained. BitFit is illustrated in b) where the linear layer is frozen except for the bias. Adapters and parallel adapters are shown in c) and d). Both have the same architecture but different placements. The adapter consists of two linear layers, L1andL2, separated by an activation function with a residual connection, similar to the FFN in a BERT model. importance of convergence for efficient fine-tuning. We show that learner modules outperform adapters by 3 GLUE points while adding a similar number of parameters, because of their quicker convergence. We also demonstrate that learners perform on par with FAR while training 7x fewer parameters, and fine-tuning 20% faster.

Background and Related Work
Parameter-efficient fine-tuning techniques attempt to reduce the number of parameters per fine-tuning task. This is done to reduce the cost of storing multiple sets of parameters on, for example, a server which executes multiple tasks based on client requests. Parameter-efficient techniques may also be computationally efficient. Adapter modules are in essence small BERT-like Feed-Forward Networks (FFNs) which are exclusively trained alongside layer normalization parameters (Houlsby et al., 2019). Adapters may be placed sequentially with modules or in parallel (He et al., 2022). Due to their small trained parameterization (i.e., the proportion of trained parameters), adapters are computationally efficient to train. The same goes for a number of methods such as BitFit, which trains only the biases of BERT models while maintaining good metric performance (Zaken et al., 2021). Difference pruning is decidedly not computationally efficient, requiring three times the parameters of a given model to achieve a parameter-efficient fine-tuning result. Difference pruning seeks to prune not the model itself, but the learned values added to pre-trained parameters during fine-tuning. In doing so, a tiny fraction of parameters are trained while producing excellent metric results (Guo et al., 2021). In the review process we were made aware of a Low-Rank Adaptation (LoRA) method by Hu et al. (Hu et al., 2021), which uses a similar architecture to Learners, but with a scaling factor after the second projection matrix. The difference between LoRA and Learners is mainly that Learners employ a priming step, which is shown to improve convergence significantly on a compressed model. All parameter-efficient methods relevant to efficient fine-tuning are illustrated in Figure 1. The commonality of parameter-efficient methods is their exploration only in large transformer-based models (all are trained on BERT LARGE or similarly large models). A question remains in their efficacy on compressed models: Can parameterefficient methods efficiently train compressed models that lack the parameterization of their proposed models?
Efficient fine-tuning attempts to reduce the computational costs of fine-tuning. Freeze-and-Reconfigure (FAR) efficiently fine-tunes DistilBERT by strategically freezing subsets of parameters in the FFNs that do not learn quickly after an initial number of training iterations, called priming steps (Vucetic et al., 2022). The FFNs are reconfigured to explicitly separate these quick-learning parameters from the slower ones. While FAR is effective at reducing the trained parameterization, training time, and memory access time, it still requires memory-intensive permutations to coherently combine results of FFN computations. FAR also requires substantially more parameters than adapters (40 million in DistilBERT versus 5 million in BERT LARGE respectively). BitFit and the various adapter configurations and architectures have not yet been tested on compressed language models. They are certainly efficient to fine-tune in terms of computational cost, but their metric performance, convergence speed, and training time must be considered.

The Necessaries of Efficient Fine-Tuning
Efficient fine-tuning methods must navigate the double bind of 1) training efficiently by reducing the number of trained parameters thereby reducing resource utilization (i.e., time, memory, compute), and 2) training effectively by ensuring quick convergence and high training scores (i.e., high GLUE scores, SQuAD accuracy, etc.). Methods that add parameters to a model, such as adapters, are still able to train efficiently since only the added parameters are trained alongside negligible layer normalization parameters (Houlsby et al., 2019). However, adapters and related methods tend to train smaller datasets such as CoLA for 20 epochs while FAR can achieve on par performance with the baseline after only 5 epochs across all datasets (Zaken et al., 2021;Houlsby et al., 2019;He et al., 2022;Vucetic et al., 2022). When attempting efficient training, it is not enough to just reduce Table 1. Metrics of different efficient fine-tuning methods training on CoLA and running on an NVIDIA Jetson Xavier NX for 20 epochs. Total parameters are the full training-time size of the model. Training time is measured as wall-clock time. Peak memory is measured using CUDA calls in PyTorch, which report the maximum amount of memory allocated during fine-tuning. Learners are presented fully later, but note that their parameterization changes over training, starting off from around 20 million and dropping after priming to 5.96 million. Peak memory in later epochs is thus much lower, but not reflected by this overall measure.

Method
Total the computational costs. The time to train (a product of the number of epochs and resource usage) must also be considered to enable on-device learning and green AI (Schwartz et al., 2020).
We found that the differential in performance between FAR and parameter-efficient methods may be explained with the convergence of training loss. Figure 2 illustrates the training loss of DistilBERT over 20 epochs on the CoLA dataset and Table 1 lists relevant performance metrics. It is clear that those methods with a small number of trained parameters tend to take longer to converge and do not converge to the same low-loss level as the baseline. For instance, BitFit converges poorly while adapters require more epochs to converge to a higher loss than baselines. In contrast, the FREEZE FFNS curve demonstrates that by training only the multi-head attention, quick convergence can be achieved and to a low loss level while training only 22% of the model. This may be the reason behind FAR's quick convergence, since it trains the multi-head attention alongside quicklearning FFN nodes. Evidently, fine-tuning pre-trained parameters is important for achieving quick convergence to a low loss, which is required for effective training. However, Table 1 also makes clear that FAR and FREEZE FFNS train more parameters than adapters. FAR is also more memory intensive than adapters in peak memory. Clearly, to achieve efficient training, complex memory operations and the number of trained parameters must be reduced from these baselines.

Learners
We propose Learner modules to ensure quick convergence to a low loss value (i.e., achieving a good metric score quickly) and to dynamically reduce the proportion of trained parameters, leading to lower resource utilization. Learner modules are similar to adapters in that they add newly initialized parameters to a model and train these parameters in lieu of the pre-trained model parameters. However, the architectures of these methods differ by both their placements and their components. The Learner module architecture is illustrated in Figure 1 a). Learners modules consist of two projection matrices added in parallel to every linear layer of a model. Learner modules also do not employ a non-linearity, meaning that they may be collapsed after fine-tuning, unlike adapters, which are permanently fixed to the model. This means that Learner modules do not affect inference efficiency. In addition, the simplicity of their architecture means that Learner modules do not incur any unnecessary overhead in contrast to FAR, whose computationally complex permutations significantly slow down fine-tuning (Vucetic et al., 2022). Learner modules by their simple architecture will therefore not impede efficient training. Learners address the question of effective training by exploiting pre-trained parameters for their quick convergence. Adapters, as was shown in Figure 2, do not converge quickly on compressed models. This is a function of both their use of newly-initialized parameters as well as a small number of trained parameters. FAR, on the other hand, converged quickly, but trained a greater proportion of parameters. To gain the benefits of both quick convergence and a small number of trained parameters, we rethink the priming technique from FAR (Vucetic et al., 2022). Priming the Learner modules instead takes the form of training the entire multi-head attention alongside the projection matrices for a number of initial epochs, p, while the rest of the model is frozen. In this way, we start off by training the relatively small multi-head attention linear layers and the Learner projections, switching to training only the projections in the latter epochs. Training alongside pre-trained parameters during priming ensures that the Learner modules have a high rate of convergence across the entirety of fine-tuning.
To show that Learners may be collapsed and added to the linear layer weights, we present a breakdown of the architecture. The projection matrices P 1 ∈ R l×d and P 2 ∈ R h×l , where l is the learner hidden size, d is the input size of the linear layer, and h is the output size of the linear layer, can be thought of as an update matrix applied after backpropagation to a linear layer weight matrix, W. The weight matrix after the learners are collapsed into it is W. This "collapse" can similarly be imagined as an identity matrix, I d , being input with W as the combination of the weights.
This may be further reduced: Thus, after fine-tuning, the Learner module may be added to the weight matrix. Henceforth, Learners are denoted as Learner l (p=x) to specify their hidden size l and the number of priming epochs x. Altogether, Learner modules occupy a middle ground between FAR, adapters, and FREEZE FFNS. Learners train significantly fewer parameters than FAR and FREEZE FFNS while maintaining the benefits of quick convergence.

Experiments
Fine-Tuning Details Learners and their counterparts are fine-tuned for five epochs to simulate realistic device constraints on fine-tuning (i.e., in time, or computational resource usage). The datasets of the GLUE benchmark are used for fine-tuning and an average GLUE score is reported for each tested method (Wang et al., 2018). Following standard practice, we have reported WNLI but have omitted it from the validation GLUE score.
All training is done on DistilBERT (Baseline). Learner modules are initialized to zero 1 . We used an adapter hidden size of 256 to give the best chance at convergence, since we found that larger hidden sizes for adapters produced better results. Parallel adapters used a hidden size of 512, a scaling factor of 4, with the adapter parallel to the FFN. Adapter-based methods had all parameters other than layer normalization frozen. FAR was re-implemented and run with a priming percentage of 1% and retention percentage of 10%, denoted as FAR 10 . In all experiments, the classifier layers appended to the model for fine-tuning were trained. We used a batch size of 16 with a learning rate of 2e −5 and a linear learning rate scheduler. As standard, AdamW is used as the optimizer. Each experiment is run for five epochs, five times, each with a new random seed. Results are reported as the average of those runs. It is evident in Table 2 that larger Learner modules produce better results with GLUE scores consistently increasing from Learner 8 to Learner 256 . Larger Learner modules are expected to produce better results due to their larger trained parameterization. However, by adding just two priming epochs, the benefits of faster convergence are realized. In each experiment, those Learner modules with priming outperform those without. Learner 64 (p = 2) even outperforms the much larger Learner 256 (p = 0), with GLUE scores of 79.07 and 78.95 respectively. The double bind of efficient fine-tuning, effective and efficient training by a reduction in trained parameters while maintaining quick convergence, has been realized by Learner 64 (p=2). Furthermore, priming seems to be the key to unlocking efficient training, despite it's greater resource usage in the initial epochs of fine-tuning. Learner modules with priming are thus successful at making a temporary trade-off of efficiency for fine-tuning efficacy.

Conclusion
We propose Learner modules, a more efficient and effective alternative to works in parameter-efficient and efficient fine-tuning. Learner modules are shown to train efficiently while also achieving high metric scores in all tested tasks. Future work should explore alternative methods to increase convergence speed. Some alternatives may include distillation or pre-fine-tuning on an out-of-distribution task similar to the target task. Alternative models such as MobileBERT should also be considered due to their even more limited parameterization.

A. Training Loss Curves for GLUE Tasks
CoLA training loss curves for related works are shown in the main paper in Figure 2. This appendix presents the training loss curves of the remaining GLUE tasks. These graphs in their totality demonstrate that learner modules have a faster convergence rate than adapters and BitFit while also converging to a lower loss value in fewer steps. Large datasets such as MNLI are run for 5 epochs while smaller datasets are run for 20 epochs. This is to ensure smaller datasets could fully converge. Note that WNLI is not presented here because the dataset is so small as to not produce a useful loss curve (only one loss evaluation in 20 epochs).
It is noted that after 5 epochs, across all training runs, learners have a lower loss value than adapters. It is only after many more epochs that parallel adapters catch up, e.g., with MRPC, RTE, and STS-B.