在针对短文本分类中文本特征稀疏难以提取、用词不规范导致OOV (out of vocabulary)等问题, 提出了基于FastText模型多通道嵌入词向量, 和GRU (gate recurrent unit)与多层感知机(multi-layer perceptron, MLP)混合网络结构(GRU-MLP hybrid network architecture, GM)的短文本分类模型GM-FastText. 该模型使用FastText模型以N-gram方式分别产生不同的嵌入词向量送入GRU层和MLP层获取短文本特征, 通过GRU对文本的特征提取和MLP层混合提取不同通道的文本特征, 最后映射到各个分类中. 多组对比实验结果表明: 与TextCNN、TextRNN方法对比, GM-FastText模型
To tackle the problems in short text classification, such as difficult extraction of sparse text features and out of vocabulary (OOV) caused by non-standard words, this study proposes a short text classification model GM-FastText based on the FastText multi-channel embedded word vector and the GRU-MLP hybrid network architecture (GM) built by a gated recurrent unit (GRU) and multi-layer perceptron (MLP). This model uses the FastText model to generate different embedded word vectors in the N-gram mode and feeds them into the GRU layer and MLP layer to obtain short text features. After the extraction of text features by GRU and the hybrid extraction of the text features in different channels in the MLP layer, they are finally mapped to each classification. The experimental results show that compared with TextCNN and TextRNN, the GM-FastText model has an
随着互联网的普及, 中国大数据产业领跑全球, 每时每刻都产生大量的短文本数据信息, 如新闻标题、应用评论、短信息等[
目前处理短文本分类思路主要有两个方向[
在数据较小情况下, 可以采用传统的机器学习方式, 如朴素贝叶斯、K-近邻、支持向量机等, 这些方法通过对数据集的预定义学习从而预测结果. 然而, 特征工程的建立往往需要大量工作量. 随着数据量的增长, 传统机器学习方式已不再适用, 卷积神经网络(convolutional neural networks, CNN)、循环神经网络(recurrent neural networks, RNN)等基于神经网络可以自主提取文本的特征, 减少大量人工标注, Kim[
实现自主提取特征的关键是字词向量化. 在NLP中广泛应用的独热编码(one-hot)将词表示为长度为词表大小的长维度向量, 其中仅一个纬度值为1及表示这个词. 这样的编码方式易于理解, 但是难以联系上下文关系, 在实际应用过程中易造成维数灾难等问题. 然而, 分布式词向量表示则在很大程度上解决了以上问题, 训练良好的分布式词向量可以通过计算向量之间欧几里得距离衡量相似度. 现阶段主流的分布式词向量训练模型有Mikolov[
为了解决短文本分类中存在的特征稀疏、用词不规范等问题, 本文根据FastText模型能产生多通道的词向量等特点, 结合GRU和MLP等模型在特征提取上的优势提出了GM-FastText模型. GM-FastText模型流程图如
GM-FastText模型结构图
FastText模型架构如
FastText模型结构
模型中{
其中,
对于大量类别的数据集, 在做类别概率归一化时会占用非常长的时间, 因此在模型输入层中引入了分层Softmax[
FastText通过词袋模型获取文本特征的同时, 还融入了N-gram信息. 其基本思想是按指定的步长进行大小为
为采用GRU模型处理字符集别的嵌入词向量, 这个模型由Chung[
GRU模型结构由
GRU模型结构图
为了使3种不同特征通道之间参数能有交互, 设计了MLP-Layer层[
MLP-Layer结构
该实验将采取多个数据集与传统的基线模型做对比, 分析模型的性能, 实验使用Python 3.8版本, 采用NVIDIA 1070显卡作为计算平台.
该实验采用短新闻标题去验证模型的效果, 由于数据库过大, 限于计算资源, 分别从THUCNews、Sogo新闻库中选取10个类别按每个类别2万条, 然后每个类别抽取2 000条以1:1分为测试集和验证集. 由于头条新闻库单个类别数量少, 选取了10个类别每个类别只抽取12 000条再分别抽取出2 000条以1:1分为测试集和验证集. 数据集的详细情况如
数据集信息表
Data set | Train | Test | Validation | category |
THUCNews | 180000 | 10000 | 10000 | 10 |
Sogo新闻库 | 180000 | 10000 | 10000 | 10 |
头条新闻库 | 100000 | 10000 | 10000 | 10 |
实验将词向量维度设置为300, 采用Adam优化器进行参数更新, 学习率设置为0.001, 批处理设置为128, 为防止过拟合随机失活率设置为0.5. 文本分类常用指标包括精确率
为了验证GM-FastText模型的有效性, 主要从两个角度进行了对比. 首先使用相同的运行参数, 且都使用随机初始化嵌入词向量对比分析了TextCNN、TextRNN、DPCNN[
各模型在3个数据集上的
从
从
根据以上分析, GM-FastText与传统文本分类模型TextCNN、TextRNN相比, 在3个数据集上
THUCNews数据集10类别
Model | Financial | Realty | Stocks | Education | Science | Society | Politics | Sports | Game | Entertainment |
TextCNN | 0.90 | 0.91 | 0.85 | 0.94 | 0.85 | 0.88 | 0.87 | 0.93 | 0.90 | 0.90 |
TextRNN | 0.88 | 0.91 | 0.82 | 0.94 | 0.83 | 0.89 | 0.87 | 0.96 | 0.92 | 0.92 |
RCNN | 0.89 | 0.91 | 0.84 | 0.95 | 0.85 | 0.90 | 0.87 | 0.96 | 0.92 | 0.92 |
DPCNN | 0.89 | 0.91 | 0.83 | 0.94 | 0.85 | 0.90 | 0.87 | 0.96 | 0.92 | 0.92 |
FastText | 0.89 | 0.92 | 0.85 | 0.95 | 0.85 | 0.90 | 0.89 | 0.97 | 0.93 | 0.93 |
Transformer | 0.86 | 0.90 | 0.80 | 0.92 | 0.80 | 0.88 | 0.86 | 0.93 | 0.90 | 0.89 |
FastText-CNN | 0.89 | 0.91 | 0.84 | 0.94 | 0.86 | 0.89 | 0.88 | 0.95 | 0.92 | 0.91 |
FastText-RNN | 0.89 | 0.92 | 0.84 | 0.94 | 0.85 | 0.89 | 0.88 | 0.96 | 0.93 | 0.92 |
GM-FastText |
头条新闻库数据集10个类别
Model | Culture | Entertainment | Sports | Financial | Car | Education | Science | Military | Travel | Word |
TextCNN | 0.87 | 0.88 | 0.92 | 0.83 | 0.91 | 0.90 | 0.84 | 0.87 | 0.88 | 0.82 |
TextRNN | 0.87 | 0.88 | 0.91 | 0.84 | 0.90 | 0.88 | 0.85 | 0.87 | 0.86 | 0.81 |
RCNN | 0.88 | 0.88 | 0.92 | 0.84 | 0.90 | 0.89 | 0.85 | 0.88 | 0.88 | 0.83 |
DPCNN | 0.82 | 0.87 | 0.92 | 0.83 | 0.89 | 0.86 | 0.84 | 0.89 | 0.86 | 0.82 |
FastText | 0.87 | 0.92 | 0.82 | 0.91 | 0.86 | 0.89 | 0.84 | |||
Transformer | 0.82 | 0.82 | 0.88 | 0.78 | 0.87 | 0.85 | 0.81 | 0.85 | 0.79 | 0.77 |
FastText-CNN | 0.89 | 0.89 | 0.93 | 0.83 | 0.91 | 0.90 | 0.84 | 0.89 | 0.87 | 0.83 |
FastText-RNN | 0.87 | 0.87 | 0.91 | 0.84 | 0.91 | 0.90 | 0.86 | 0.87 | 0.86 | 0.82 |
GM-FastText | 0.88 | 0.89 | 0.86 |
Sogo新闻库数据集10个类别
Model | Culture | Entertainment | Sports | Financial | Car | Education | Science | Military | Travel | Word |
TextCNN | 0.83 | 0.80 | 0.93 | 0.96 | 0.85 | 0.89 | 0.85 | 0.96 | 0.92 | 0.93 |
TextRNN | 0.84 | 0.80 | 0.93 | 0.96 | 0.85 | 0.88 | 0.84 | 0.97 | 0.92 | 0.92 |
RCNN | 0.88 | 0.83 | 0.95 | 0.97 | 0.88 | 0.89 | 0.87 | 0.97 | 0.95 | 0.92 |
DPCNN | 0.85 | 0.81 | 0.93 | 0.96 | 0.87 | 0.88 | 0.86 | 0.97 | 0.93 | 0.90 |
FastText | 0.88 | 0.83 | 0.95 | 0.98 | 0.89 | 0.91 | 0.88 | 0.98 | 0.95 | |
Transformer | 0.81 | 0.79 | 0.88 | 0.96 | 0.83 | 0.86 | 0.83 | 0.96 | 0.89 | 0.89 |
FastText-CNN | 0.88 | 0.84 | 0.94 | 0.96 | 0.87 | 0.87 | 0.86 | 0.97 | 0.93 | 0.94 |
FastText-RNN | 0.85 | 0.82 | 0.93 | 0.96 | 0.87 | 0.88 | 0.84 | 0.97 | 0.95 | 0.93 |
GM-FastText | 0.95 |
各模型在3个数据集上的准确率值如
由以上数据可得, GM-FastText与传统文本分类模型TextCNN、TextRNN相比在3个数据集上准确率平均提升1.96、2.08个百分点; GM-FastText相比于FastText, FastText-CNN和FastText-RNN在3个数据集上准确率平均提升0.42、1.06、1.41个百分点.
各模型在不同数据集的准确率(%)
Model | THUCNews | 头条新闻库 | Sogo新闻库 |
TextCNN | 89.95 | 87.72 | 89.59 |
TextRNN | 90.05 | 87.09 | 89.76 |
RCNN | 90.61 | 88.04 | 91.65 |
DPCNN | 90.03 | 86.28 | 90.13 |
FasTText | 91.13 | 88.39 | 92.36 |
Transformer | 87.88 | 82.73 | 87.49 |
FastText-CNN | 90.50 | 88.26 | 91.17 |
FastText-RNN | 90.68 | 87.58 | 90.67 |
GM-FastText |
同时从
总之, 针对3个数据集
通过词向量表征和模型结构两个切入点, 构建了一个多通道嵌入词的简易网络短文本分类模型GM-FastText. 通过FastText生成3种不同N-gram嵌入词向量, 以多通道的形式输入到GM结构中, 突出文本特征然后通过全联接层得到结果. GM-FastText模型利用N-gram特殊的滑窗结构构建特殊的字词向量, 对于短新闻中一些极简词也有对应向量解决大多数的OOV问题, 提高了部分类别新闻分类准确率. 尽管MLP提取整合多特征向量有着良好性能, 但是特征向量经过1次MLP-Layer层特征识别有限, 在接下来的工作中应着重优化MLP-Layer尝试多次经过MLP-Layver层多次提取词向量特征.
杨朝强, 邵党国, 杨志豪, 等. 多特征融合的中文短文本分类模型. 小型微型计算机系统, 2020, 41(7): 1421–1426.
段丹丹, 唐加山, 温勇, 等. 基于BERT模型的中文短文本分类算法. 计算机工程, 2021, 47(1): 79–86.
et al. Bag of tricks for efficient text classification. Proceedings of the 15th Conference of the European Chapter of the Association for Computational Linguistics: Volume 2, Short Papers. Valencia: Association for Computational Linguistics, 2017. 427–431.]]>
et al. Efficient estimation of word representations in vector space. arXiv: 1301.3781, 2013.]]>
张焱博, 郭凯. 基于Fasttext和多融合特征的文本分类模型. 计算机仿真, 2021, 38(7): 461–466.
汪家成, 薛涛. 基于FastText和关键句提取的中文长文本分类. 计算机系统应用, 2021, 30(8): 213–218, doi: 10.15888/j.cnki.csa.008007.
范昊, 李鹏飞. 基于FastText字向量与双向GRU循环神经网络的短文本情感分析研究——以微博评论文本为例. 情报科学, 2021, 39(4): 15–22, doi: 10.13833/j.issn.1007-7634.2021.04.003.
et al. Empirical evaluation of gated recurrent neural networks on sequence modeling. arXiv: 1412.3555, 2014.]]>
et al. MLP-mixer: An all-MLP architecture for vision. arXiv: 2105.01601, 2021.]]>
et al. Recurrent convolutional neural networks for text classification. Proceedings of the 29th AAAI Conference on Artificial Intelligence. Austin: AAAI, 2015. 2267–2273.]]>