arXiv(opens in a new tab)Computer ScienceDec 2021

Manuscript Offprint

arXiv:2112.12650

Distilling the Knowledge of Romanian BERTs Using Multiple Teachers

Andrei-Marius Avram, Darius Catrina, Dumitru-Clementin Cercel, Mihai Dascualu, Traian Rebedea, Vasile Puaics, Dan Tufics

Abstract

Running large-scale pre-trained language models in computationally constrained environments remains a challenging problem yet to be addressed, while transfer learning from these models has become prevalent in Natural Language Processing tasks. Several solutions, including knowledge distillation, network quantization, or network pruning have been previously proposed; however, these approaches focus mostly on the English language, thus widening the gap when considering low-resource languages. In this work, we introduce three light and fast versions of distilled BERT models for the Romanian language: Distil-BERT-base-ro, Distil-RoBERT-base, and DistilMulti-BERT-base-ro. The first two models resulted from the individual distillation of knowledge from two base versions of Romanian BERTs available in literature, while the last one was obtained by distilling their ensemble. To our knowledge, this is the first attempt to create publicly available Romanian distilled BERT models, which were thoroughly evaluated on five tasks: part-of-speech tagging, named entity recognition, sentiment analysis, semantic textual similarity, and dialect identification. Our experimental results argue that the three distilled models offer performance comparable to their teachers, while being twice as fast on a GPU and ∼\sim35% smaller. In addition, we further test the similarity between the predictions of our students versus their teachers by measuring their label and probability loyalty, together with regression loyalty - a new metric introduced in this work. Keywords: Knowledge Distillation, BERT, Romanian language, Multiple Teachers, Loyalty

Andrei-Marius Avram1, Darius Catrina*3, Dumitru-Clementin Cercel2, Mihai Dascalu2,
Traian Rebedea2, Vasile Păiș1, Dan Tufiș1
Research Institute for Artificial Intelligence, Romanian Academy1
University Politehnica of Bucharest, Faculty of Automatic Control and Computers2
Duke University3
{andrei.avram, vasile, tufis}@racai.ro, {dumitru.cercel, mihai.dascalu, traian.rebedea}@upb.ro

Abstract content

1. Introduction

Knowledge transfer from Transformer-based language models [Vaswani et al. (2017] trained on large amounts of data achieves state-of-the-art results on most Natural Language Processing (NLP) tasks [Devlin et al. (2019, Liu et al. (2019, He et al. (2020]. However, the best performing models usually have billions [Brown et al. (2020] or even trillions [Fedus et al. (2021] of parameters, making them impractical in certain real-world situations. Moreover, both training and using these language models usually comes at a high environmental cost [Strubell et al. (2019].

Several attempts were made to reduce the size of models by distilling their knowledge [Hinton et al. (2015] accumulated during the pre-training phase [Sanh et al. (2019], after fine-tuning the model on a specific task [Turc et al. (2019], or both pre-training and fine-tuning [Jiao et al. (2020]. Other methods consider shrinking the size of the models by either quantizing their weights to integer values [Shen et al. (2020], or pruning parts of the neural network [Brix et al. (2020]. In addition, efficient attention mechanisms were developed to overcome the quadratic bottleneck in the sequence length of multi-head attention [Zaheer et al. (2020, Choromanski et al. (2020].

However, the vast majority of these efforts focused on developing English models, and little attention was paid on increasing the efficiency of pre-trained models on other languages, with few singular cases of such compressed models like BERTino [Muffo and Bertino (2020] for Italian, MBERTA for Arabic [Alyafeai and Ahmad (2021], or GermDistilBERT for German. As a response to this issue, we focus on Romanian, a language on which BERT has recently attracted a surge of attention from the local community and has shown promising results in various areas like dialect identification [Zaharia et al. (2021, Popa and Ștefănescu (2020, Zaharia et al. (2020], document classification [Avram et al. (2021] or satire detection in news [Rogoz et al. (2021]. Thus, our work introduces three compressed BERT versions for the Romanian language that were obtained through a distillation process:

  • Distil-BERT-base-ro was obtained by distilling the knowledge of BERT-base-ro [Dumitrescu et al. (2020] using its original training corpus and tokenizer;
  • Distil-RoBERT-base was created from RoBERT-base [Masala et al. (2020] in similar conditions (i.e., using both original training corpus and tokenizer);
  • DistilMulti-BERT-base-ro considered the distillation of the knowledge from an ensemble consisting of BERT-base-ro and RoBERT-base, while relying on the combined corpus and coupled with the tokenizer of the former model.

Our three compressed models were further evaluated on five Romanian datasets and the results showed that they maintained most of the performance of the original models, while being approximately twice as fast when run on a GPU. In addition, we also measure the label, probability and regression loyalties between each of the three distilled models and their teachers, as quantifying the performance on specific tasks does not show how similar the predictions between a teacher and a student really are. The models, together with the distillation and evaluation scripts were open-sourced to improve the reproducibility of this work.

The rest of the paper is structured as follows. The next section presents a series of solutions related to the knowledge distillation of pre-trained language models. The third section outlines our approach of distilling the knowledge of Romanian BERTs, whereas the fourth section presents the evaluation setup and their performance on various Romanian tasks. The fifth section evaluates the prediction loyalty between each distilled version and its teacher, while the sixth section evaluates their inference speed. The final section concludes our work and outlines potential future work.

References (41)