基于Transformer的大规模模型(如Bidirectional Encoder Representations from Transformers(BERT,双向编码器表征Transformer模型))被广泛应用于自然语言处理(NLP)任务中:这类模型首先用包含数百万参数的大型语料库进行预训练,随后针对下游NLP任务进行微调。这类大规模模型的主要局限之一是,由于模型体积大、推理延迟高,无法部署在资源受限的设备上。为克服这些局限,可将这类大规模模型转换为优化的FlatBuffer格式,该格式专为资源受限边缘设备的部署而定制。本文中,我们评估了经FlatBuffer转换的MobileBERT模型在三种不同边缘设备上的性能,这些模型针对RepLab 2013数据集中的英文推文声誉分析任务进行了微调。此外,本研究还对部署后的模型开展了评估,细致衡量了它们的延迟、性能与资源效率。实验结果表明,与原始BERT large模型相比,经转换和量化的MobileBERT模型体积缩小160倍,准确率仅下降4.1%,且在边缘设备上每秒至少可分析一条推文。此外,本研究还凸显了TinyML系统的隐私保护特性——所有数据都在无服务器环境中本地处理。
英文摘要:
Large-scale transformer-based models like the Bidirectional Encoder Representations from Transformers (BERT) are widely used for Natural Language Processing (NLP) applications, wherein these models are initially pre-trained with a large corpus with millions of parameters and then fine-tuned for a downstream NLP task. One of the major limitations of these large-scale models is that they cannot be deployed on resource-constrained devices due to their large model size and increased inference latency. In order to overcome these limitations, such large-scale models can be converted to an optimized FlatBuffer format, tailored for deployment on resource-constrained edge devices. Herein, we evaluate the performance of such FlatBuffer transformed MobileBERT models on three different edge devices, fine-tuned for Reputation analysis of English language tweets in the RepLab 2013 dataset. In addition, this study encompassed an evaluation of the deployed models, wherein their latency, performance, and resource efficiency were meticulously assessed. Our experiment results show that, compared to the original BERT large model, the converted and quantized MobileBERT models have 160$\times$ smaller footprints for a 4.1% drop in accuracy while analyzing at least one tweet per second on edge devices. Furthermore, our study highlights the privacy-preserving aspect of TinyML systems as all data is processed locally within a serverless environment.
Hardware Acceleration of Fully Quantized BERT for Efficient Natural Language Processing
National Laboratory of Pattern Recognition, Institute of Automation, Chinese Academy of Sciences(中国科学院自动化研究所模式识别国家重点实验室);School of Future Technology, University of Chinese Academy of Sciences(中国科学院大学未来技术学院)