摘要
针对小样本学习标注训练样本过少,导致特征表达力弱的问题,本文结合有监督主题模型(Supervised LDA, SLDA)和动态路由算法提出一种新的动态路由原型网络模型(Dynamic routing prototypical network based on SLDA, DRP‑SLDA)。利用SLDA主题模型建立词汇与类别之间的语义映射,增强词的类别分布特征,从词粒度角度编码获得样本的语义表示。提出动态路由原型网络(Dynamic routing prototypical network,DR‑Proto),通过提取交叉特征利用样本之间的语义关系,采用动态路由算法迭代生成具有类别代表性的动态原型,旨在解决特征表达问题。实验结果表明,DRP‑SLDA模型能有效提取词的类别分布特征,且获取动态原型提高类别辨识力,从而能够有效提升小样本文本分类的泛化性能。
有监督深度学
C‑way K‑shot表示含有C个类别且每类有K个标记样本的小样本分类问题。令且。从训练集选C个类别,每类选K个有标签样本,作为支持集,表示第i个样本,为的类标签;每类另外选L个无标签样本作为查询集,表示第q个样本,为的类标签。测试集由C类的有标签支持集和无标签查询集构成。元学习方法仅从中采样1组支持集和查询集,样本过少模型难以学习良好特征表示。借鉴文献[

图1 元训练样本
Fig.1 Meta‑training samples

图2 DRP‑SLDA模型的C‑way K‑shot(C=3,K=2)框架
Fig.2 C‑way K‑shot (C=3, K=2) architecture of DRP‑SLDA model
为获得每个类别的词分布特征,本文提出基于SLDA主题模型的词编码方法,即
SLDA主题模型的概率图模型如

图3 SLDA概率图模型
Fig.3 SLDA probabilistic graphical model
(1) |
(2) |
(3) |
式中:表示样本i的词分配给主题t的概率;表示主题t分配给词w的概率;表示主题t属于类别j的概率。表示第i个样本被赋予主题t的次数;表示词w被赋予主题t的次数;表示类别j被赋予主题t的次数。为主题t的Dirichlet先验;为词w的Dirichlet先验;为类别j的Dirichlet先验。t=1,…,T;w=1,…,V;j=1,…,C。
小样本学习因样本匮乏难以较好学习词特征,由于SLDA主题模型的和识别词汇与类别之间的精准映射,基于SLDA的Encoder旨在从单词‑类别分布中增强特征表示学习,如

图4 基于SLDA的Encoder架构
Fig.4 Encoder architecture based on SLDA
基于SLDA计算单词对于特定类的权重为
(4) |
式中:,l表示每个样本中含有的单词总数,C表示类别总数;表示主题的类别概率分布;表示主题的词概率分布,T是主题数。由计算类别-词汇的精准映射,从而获得单词特定类中的分布特征。信息熵衡量词分类的不确定性,熵值[0,1]越大越难判别所属类别。S()表示第i个样本的第w个单词是第j类的概率值,S()越大,词在特定类中重要性越大。
提取源集中单词通用性特
(5) |
式中:表示第i个样本中的第w个词;为平滑系数;表示词频。降低源集高频词的权重,获得在通用类中的重要性。则表示为
和互补难以设计合理的组合函数,且两者对分类重要性一致。关键词与词序和语境有关,通过BiLSTM融合拼接和,有
(6) |
式中:表示样本i全部单词的特征表示,。
令为样本i全部单词的特征表示,,则第i个样本的单词权重为
(7) |
式中:、为可学习参数;为激活函数。通过归一化获得第i个样本l个单词的权重。
为单词赋予不同权重,则有
(8) |
式中:表示词经过word2vec的低维向量;为权重,通过加权求和获得样本标量值,令,则样本向量。
Encoder利用SLDA从词粒度角度引入主题特征编码,获得语义增强的样本表示。
基于SLDA的Encoder,提出动态路由原型网络DR‑Proto。利用支持集和查询集的样本语义交叉特征获得原型,使分类边界更清晰。DR‑Proto网络如
(9) |
(10) |
式中:为支持集类j的第i个样本;为查询集第q个样本;、为共享参数。通过特征映射使距离尽可能近,,,。[
(11) |
考虑支持集和查询集满足独立同分布,通过提取交叉特征以利用文本语义关系,有
(12) |
式中:为元素积;表示取绝对值。若和属于同类,样本间的距离近,则交叉特征多;否则,样本间的距离远,则交叉特征少。通过交叉特征,使样本特征相应增强或弱化。

图5 DR‑Proto 网络架构
Fig.5 DR‑Proto network architecture
计算权重,获得不同样本对原型的重要性,即有
(13) |
式中耦合系数为先验知识,为动态路由迭代次数。每个样本训练之前等概率影响原型,从而初始化使均匀分布。
根据权重计算每类的原型,有
(14) |
式中:为第g次迭代时类j第i个样本的权重;K为每个类别的样本个数。为交叉特征计算如
为了增大同类样本相关性而降低不同类相关性,自上而下调整耦合系数,有
(15) |
式中:若属于原型,则增大耦合系数,增强该样本对原型的影响;若不属于原型,则减小耦合系数,使该样本的影响边缘化。
由融合动态路由算
为验证模型有效性,利用20newsgroup英文数据集、FewRel关系数据集和Sogou中文数据集,采样支持集和查询集,构建C‑way K‑shot分类任务进行对比实验,数据集描述如
对比模型有:(1) Finetun
DRP‑SLDA模型与上述6种模型在FewRel和20newsgroup数据
由
DRP‑SLDA模型对比模型(1~5)在20newsgroup数据集上准确率提升10%~30%,表明DRP‑SLDA模型引入源集是有效的,能从不同角度提取词汇特征。DRP‑SLDA模型相较于Distributional signatures模型在20newsgroup数据集上准确率分别提高8.6%、16.6%。原因在于Distributional signatures模型仅考虑词汇特征没有考虑样本权重对分类的影响,而DRP‑SLDA模型利用SLDA模型增强词分布特征且DR‑Proto网络为样本赋予权重获得动态原型。
消融方法简介:(1) DRP‑SLDA:本文提出的小样本分类模型。(2) DRP‑SLDA_NR:消融DRP‑SLDA模型中源集在数据扩充上的影响。(3) DRP‑SLDA_NS:消融DRP‑SLDA模型中SLDA主题模型对词分布特征的影响。(4) DRP‑SLDA_ND:消融DRP‑SLDA模型中交叉特征的影响。(5) DRP‑SLDA_NDR:消融DRP‑SLDA模型中源集数据扩充和交叉特征的共同影响。(6) DRP‑SLDA_NDS:消融DRP‑SLDA模型中SLDA主题模型和交叉特征的共同影响。
为了分析DRP‑SLDA模型不同组件对分类效果的影响,在Sogou和20newsgroup数据集上分别进行3‑way 1‑shot、5‑way 5‑shot消融实验,实验结果如

图6 Sogou数据集在3‑way 1‑shot下消融方法分类结果
Fig.6 Sogou data set classification results of ablation methods under 3‑way 1‑shot

图7 20newsgroup数据集在5‑way 5‑shot下消融方法分类结果
Fig.7 20newsgroup data set classification results of ablation methods under 5‑way 5‑shot
如
如

图8 消融方法在20newsgroup数据集的PCA可视化比较
Fig. 8 PCA visualization comparison of ablation methods in 20newsgroup data set
为了验证DR‑Proto网络中动态路由算法对DRP‑SLDA模型分类效果的影响,在FewRel数据集上进行5‑way实验,动态路由算法的随不同迭代次数的可视化如

图9 不同动态路由迭代次数的样本(特征)可视化结果
Fig.9 Visualization results of samples (features) of different dynamic routing iteration times
本文提出一种基于SLDA和动态路由的原型网络模型DRP‑SLDA,利用SLDA模型获得词汇‑类别的语义映射增强词的分布特征,结合动态路由算法更新样本权重为不同样本赋予权重获得动态原型,从而有效提升模型的泛化性能。在多个数据集上的对比实验表明了DRP‑SLDA模型的有效性。下一步将对多标签小样本元学习方法展开研究。
参考文献
Kuang Shaohui, Li Junhui, Branco A, et al. Attention focusing for neural machine translation by bridging source and target embedding [C]//Proceedings of the 56th Annual Meeting of the Association for Computational Linguistics. Melbourne, Australia: Association for Computational Linguistics, 2018: 1767‑1776. [百度学术]
Zhou Chunting, Sun Chonglin, Liu Zhiyuan, et al. A C‑LSTM neural network for text classification[J]. Computer Science, 2015, 1(4): 39‑44. [百度学术]
Yang Zichao, Yang Diyi, Dyer C, et al. Hierarchical attention networks for document classification [C]//Proceedings of the 2016 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies. San Diego, California: Association for Computational Linguistics, 2016: 1480‑1489. [百度学术]
Norbert J, Wlodzislaw D, Krzysztof G. Meta‑learning in Computational Intelligence [M]. Berlin, Germany: Springer, 2011: 97‑115. [百度学术]
Lake B L, Salakhutdinov R, Tenenbaum J B. One‑shot learning by inverting a compositional causal process [C]//Proceedings of Advances in Neural Information Processing Systems. United States: Lake Tahoe, 2013: 2526‑2534. [百度学术]
Bengio Y, Guyon G, Dror V, et al. Deep learning of representations for unsupervised and transfer learning [J]. Workshop on Unsupervised & Transfer Learning, 2012: 17‑36. [百度学术]
Hochreiter S, Younger A S, Conwell P R. Learning to learn using gradient descent [C]//Proceedings of International Conference on Artificial Neural Networks. Berlin, Heidelberg: Springer, 2001: 87‑94. [百度学术]
HUISAN M, VAN R J N, PLAAT A. A survey of deep meta-learning[J]. Artificial Intelligence Review, 2021, 54(6): 4483-4541. [百度学术]
Vinyals O, Blundell C, Lillicrap T, et al. Matching networks for one shot learning [C]//Proceedings of Advances in Neural Information Processing Systems. Montreal, Quebec Canada: Morgan Kaufmann, 2016: 3637‑3645. [百度学术]
Vilalta R, Drissi Y. A perspective view and survey of meta‑learning [J]. Artificial Intelligence Review, 2002, 18(2): 77‑95. [百度学术]
Snell J, Kevin S, Richard Z. Prototypical networks for few‑shot learning [C]//Proceedings of Advances in Neural Information Processing Systems. Montreal, Quebec Canada: Morgan Kaufmann, 2017: 4077‑4087. [百度学术]
FORT S. Gaussian prototypical networks for few shot learning on omniglot [C]//Proceedings of International Conference on Learning Representations. Massachusetts, USA: OpenReview.net, 2018. DOI:10.48550/arXiv.1708.02735. [百度学术]
Gao Tianyu, Han Xu, Liu Zhiyuan, et al. Hybrid attention‑based prototypical networks for noisy few‑shot relation classification [C]//Proceedings of the AAAI Conference on Artificial Intelligence. [S.l]: AAAI, 2019: 6407‑6414. [百度学术]
SUN Shengli, SUN Qingfeng, ZHON K, et al. Hierarchical attention prototypical networks for few-shot text classification [C]//Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing and the 9th International Joint Conference on Natural Language Processing. Hong Kong, China: Association for Computational Linguistics, 2019: 476-485. [百度学术]
唐焕玲, 窦全胜, 于立萍,等. 有监督主题模型SLDA‑TC文本分类新方法 [J]. 电子学报, 2019, 47(6): 1300‑1308. [百度学术]
Tang Huanling, Dou Quansheng, Yu Liping, et al. SLDA‑TC: A novel text categorization approach based on supervised topic model[J]. Acta Electronica Sinica, 2019, 47(6): 1300‑1308. [百度学术]
Sabour S, Frosst N, Hinton G E. Dynamic routing between capsules [C]//Proceedings of Advances in Neural Information Processing Systems. Long Beach, CA,USA: Curran Associates Inc, 2017: 3856‑3866. [百度学术]
BAO Yujia, WU Menghua, CHANG Shiyu, et al. Few-shot text classification with distributional signatures [D]. Boston, Cambridge, USA: Massachusetts Institute of Technology, 2020. [百度学术]
Sepp H, Jurgen S. Long short‑term memory [J]. Neural Computation, 1997, 9(8): 1735‑1780. [百度学术]
Arora S, Liang Yingyu, Ma Tengyu. A simple but tough‑to‑beat baseline for sentence embeddings [C]//Proceedings of International Conference on Learning Representations. Massachusetts, USA: Open Review. net, 2017. [百度学术]
Geng Ruiying, Li Binhua, Li Yongbin, et al. Induction networks for few‑shot text classification [C]//Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing and the 9th International Joint Conference on Natural Language Processing. Hong Kong, China: Association for Computational Linguistics, 2019: 3902‑3911. [百度学术]
Hinton G E, Krizhevsky A, Wang S D. Transforming auto‑encoders [C]//Proceedings of Artificial Neural Networks & Machine Learning‑International Conference on Artificial Neural Networks. Berlin, Heidelberg: Springer, 2011: 44‑51. [百度学术]
Chen Weiyu, Liu Yencheng, Kira Z, et al. A closer look at few‑shot classification [C]//Proceedings of In International Conference on Learning Representations. Massachusetts, USA: OpenReview. net, 2019. [百度学术]
Finn C, Abbeel P, Levine S. Model‑agnostic meta‑learning for fast adaptation of deep networks [C]//Proceedings of the 34th International Conference on Machine Learning. Australia: PMLR, 2017: 1126‑1135. [百度学术]
Bertinetto L, Henriques J F, Torr P, et al. Meta‑learning with differentiable closed‑form solvers [C]//Proceedings of In International Conference on Learning Representations. Massachusetts, USA: OpenReview. net, 2019. [百度学术]