计算机与现代化 ›› 2022, Vol. 0 ›› Issue (06): 1-7.

• 算法设计与分析 •    下一篇

一种基于BERT和池化操作的文本分类模型

  

  1. (1.东华理工大学软件学院,江西南昌330013;2.东华理工大学信息工程学院,江西南昌330013)
  • 出版日期:2022-06-23 发布日期:2022-06-23
  • 作者简介:张军(1978—),男(土家族),湖南常德人,副教授,硕士生导师,博士,研究方向:处理器/存储器性能功耗优化,自然语言处理,E-mail: zhangjun_whu@whu.edu.cn; 通信作者:邱龙龙(1997—),男,安徽安庆人,硕士研究生,研究方向:深度学习,自然语言处理,E-mail: 792688763@qq.com。
  • 基金资助:
    国家自然科学基金资助项目(62162002, 61662002, 61972293, 61902189); 江西省自然科学基金资助项目(20212BAB202002);江苏省自然科学基金资助项目(BK20180821)

A Text Classification Model Based on BERT and Pooling Operation

  1. (1. School of Software, East China University of Technology, Nanchang 330013, China; 
    2. School of Information Engineering, East China University of Technology, Nanchang 330013, China)
  • Online:2022-06-23 Published:2022-06-23

摘要: 使用预训练语言模型的微调方法在以文本分类为代表的许多自然语言处理任务中取得了良好的效果,尤其以基于Transformer框架的BERT模型为典型代表。然而,BERT直接使用[CLS]对应的向量作为文本表征,没有从全局和局部考虑文本的特征,从而限制了模型的分类性能。因此,本文提出一种引入池化操作的文本分类模型,使用平均池化、最大池化以及K-MaxPooling等池化方法从BERT输出矩阵中提取文本的表征向量。实验结果表明,与原始的BERT模型相比,本文提出的引入池化操作的文本分类模型具有更好的性能,在实验的所有文本分类任务中,其准确率和F1-Score值均优于BERT模型。

关键词: 文本分类, 分类模型, BERT, 平均池化, 最大池化, K-MaxPooling

Abstract: The fine-tuning method using the pre-trained language model has achieved good results in many natural language processing tasks represented by text classification, BERT model based on the Transformer framework as a typical representative especially. However, BERT uses the vector corresponding to [CLS] as the text representation directly, and does not consider the local features and global features of texts, which limits the classification performance of the model. Therefore, this paper proposes a text classification model that introduces a pooling operation, and uses pooling methods such as average pooling, maximum pooling, and K-MaxPooling to extract the representation vector of texts from the output matrix of BERT. The experimental results show that compared with the original BERT model, the text classification model with pooling operation proposed in this paper has better performance. In all text classification tasks in the experiment, its accuracy and F1-Score value are better than BERT model.

Key words: text classification, classification model, BERT, mean-pooling, max-pooling, K-MaxPooling