A dap L e R : Speeding up Inference by Adaptive Length Reduction (2022)

Abstract: Pre-trained language models have shown stellar performance in various downstream tasks. But, this usually comes at the cost of high latency and computation, hindering their usage in resource-limited settings. In this work, we propose a novel approach for reducing the computational cost of BERT with minimal loss in downstream performance. Our method dynamically eliminates less contributing tokens through layers, resulting in shorter lengths and consequently lower computational cost. To determine the importance of each token representation, we train a Contribution Predictor for each layer using a gradient-based saliency method. Our experiments on several diverse classification tasks show speedups up to 22x during inference time without much sacrifice in performance. We also validate the quality of the selected tokens in our method using human annotations in the ERASER benchmark. In comparison to other widely used strategies for selecting important tokens, such as saliency and attention, our proposed method has a significantly lower false positive rate in generating rationales. Our code is freely available at https://github.com/amodaresi/AdapLeR .

## introduction while large-scale pre-trained language models exhibit remarkable performances on various nlp benchmarks, their excessive computational costs and high inference latency have limited their usage in resource-limited settings. in this regard, there have been various attempts at improving the efficiency of bert-based models @xcite , including knowledge distilation @xcite @xcite @xcite , quantization @xcite @xcite , weight ## analysis in this section, we first conduct an experiment to support our choice of saliency scores as a supervision in measuring the importance of token representations. next, we evaluate the behavior of contribution predictors in identifying the most important tokens in the adapler. ## conclusion in this paper, we introduced adapler, a novel method that accelerates inference by dynamically identifying and dropping less contributing token representations through layers of bert-based models. specifically, adapler accomplishes this by training a set of contribution predictors based on saliencies extracted from a fine-tuned model and applying a gradual masking technique to simulate input-adaptive token removal during training. empirical results on eight diverse text classification tasks show considerable improvements over existing methods. furthermore, we demonstrated that contribution predictors generate rationales that are highly in line with those manually specified by humans. as future work, we aim to apply our technique to more tasks and see whether it can be adapted to those tasks that require all token representations to be present in the final layer of the model (e.g., question answering). additionally, combining our width-based strategy with a depthbased one (e.g., early exiting) might potentially yield greater efficiency, something we plan to pursue as future work.