一句话:通过挖掘 Stack Overflow 中 BERT 相关帖子,实证分析复用预训练 NLP 模型时客户端代码出现的 bug 类型与分布。
预训练 NLP 模型(尤其是 BERT)被广泛复用于下游文本任务,甚至医疗、航空等安全关键场景;但在新场景中复用模型受训练数据、模型结构、规范和使用方式等限制,容易在客户端代码中引入缺陷。本文以 BERT 为对象研究复用预训练模型是否会传播 bug,从 Stack Overflow 挖掘 80 个相关帖子,归纳客户端代码中观察到的四类 bug。结果显示:公平性 bug 占 13.75%,参数 bug 占 28.75%,token bug 占 15%,版本相关 bug 占 16.25%。该工作揭示了预训练 NLP 模型复用中的缺陷模式,为后续工具与最佳实践提供依据。
In this digital era, the textual content has become a seemingly ubiquitous part of our life. Natural Language Processing (NLP) empowers machines to comprehend the intricacies of textual data and eases human-computer interaction. Advancement in language modeling, continual learning, availability of a large amount of linguistic data, and large-scale computational power have made it feasible to train models for downstream tasks related to text analysis, including safety-critical ones, e.g., medical, airlines, etc. Compared to other deep learning (DL) models, NLP-based models are widely reused for various tasks. However, the reuse of pre-trained models in a new setting is still a complex task due to the limitations of the training dataset, model structure, specification, usage, etc. With this motivation, we study BERT, a vastly used language model (LM), from the direction of reusing in the code. We mined 80 posts from Stack Overflow related to BERT and found 4 types of bugs observed in clients’ code. Our results show that 13.75% are fairness, 28.75% are parameter, 15% are token, and 16.25% are version-related bugs.