《计算机应用》唯一官方网站 ›› 2023, Vol. 43 ›› Issue (9): 2753-2759.DOI: 10.11772/j.issn.1001-9081.2022091347
收稿日期:
2022-09-09
修回日期:
2022-11-11
接受日期:
2022-11-15
发布日期:
2023-02-14
出版日期:
2023-09-10
通讯作者:
刘蓉
作者简介:
张心月(1997—),女,河南周口人,硕士研究生,主要研究方向:模式识别、方面级情感分析基金资助:
Xinyue ZHANG, Rong LIU(), Chiyu WEI, Ke FANG
Received:
2022-09-09
Revised:
2022-11-11
Accepted:
2022-11-15
Online:
2023-02-14
Published:
2023-09-10
Contact:
Rong LIU
About author:
ZHANG Xinyue, born in 1997, M. S. candidate. Her research interests include pattern recognition, aspect-based sentiment analysis.Supported by:
摘要:
针对基于预训练模型的方面级情感分析普遍使用端到端框架,存在上下游阶段任务不一致、难以有效建模方面词和上下文之间关系的问题,提出一种融合提示知识的方面级情感分析方法。首先基于Prompt机制构造提示文本,将该提示文本与原始句子和方面词进行拼接,并把得到的结果作为预训练模型BERT(Bidirectional Encoder Representation from Transformers)的输入,以有效捕获方面词和上下文之间的语义联系,同时提升模型对情感分析任务的感知能力;然后构建情感标签词表,并将它融入情感标签词映射层,以减小模型的搜索空间,使预训练模型获取标签词表中丰富的语义知识,并增强模型的学习能力。实验结果表明,所提方法在SemEval2014 Task4数据集的Restaurant、Laptop两个领域数据集和ChnSentiCorp数据集上的F1值分别达到了77.42%、75.20%、94.89%,与Glove-TextCNN、P-tuning等主流方面级情感分析方法相比提高了0.65~10.71、1.02~9.58与0.83~6.40个百分点,验证了所提方法对方面级情感分析的有效性。
中图分类号:
张心月, 刘蓉, 魏驰宇, 方可. 融合提示知识的方面级情感分析方法[J]. 计算机应用, 2023, 43(9): 2753-2759.
Xinyue ZHANG, Rong LIU, Chiyu WEI, Ke FANG. Aspect-based sentiment analysis method with integrating prompt knowledge[J]. Journal of Computer Applications, 2023, 43(9): 2753-2759.
数据集 | |
---|---|
SemEval2014 Task4 | Aspects, it was [MASK] |
ChnSentiCorp | 是好评吗?[MASK] |
表1 提示文本设计示例(部分)
Tab. 1 Some examples of prompt texts (partial)
数据集 | |
---|---|
SemEval2014 Task4 | Aspects, it was [MASK] |
ChnSentiCorp | 是好评吗?[MASK] |
数据集 | 标签 | 标签词 |
---|---|---|
SemEval2014 Task4 | Positive | good,wonderful,great,… |
Negative | bad,upset,worse,… | |
Neutral | indifferent, just ok,… | |
ChnSentiCorp | Positive | 是,对,… |
Negative | 否,错,不,… |
表2 扩展标签词的示例
Tab. 2 Examples of expanded label words
数据集 | 标签 | 标签词 |
---|---|---|
SemEval2014 Task4 | Positive | good,wonderful,great,… |
Negative | bad,upset,worse,… | |
Neutral | indifferent, just ok,… | |
ChnSentiCorp | Positive | 是,对,… |
Negative | 否,错,不,… |
数据集 | 不同情感极性样本数 | |||
---|---|---|---|---|
Positive | Neutral | Negative | ||
Laptop | train | 994 | 464 | 870 |
test | 341 | 169 | 128 | |
Restaurant | train | 2 164 | 637 | 807 |
test | 728 | 196 | 196 |
表3 SemEval2014 Task4数据集
Tab. 3 SemEval2014 Task4 datasets
数据集 | 不同情感极性样本数 | |||
---|---|---|---|---|
Positive | Neutral | Negative | ||
Laptop | train | 994 | 464 | 870 |
test | 341 | 169 | 128 | |
Restaurant | train | 2 164 | 637 | 807 |
test | 728 | 196 | 196 |
评论文本 | 标签 |
---|---|
很旧的设施,服务也不好,感觉一般,不能和大城市比。 | 0 |
第一感觉就是门童服务很到位,前台服务也面带微笑。房间宽敞明亮,上网速度也很快。很满意的一家酒店! | 1 |
服务没有最坏只有更坏,先是早上没热水然后电梯也坏了。 | 0 |
表4 ChnSentiCorp数据集样例
Tab. 4 Examples of ChnSentiCorp dataset
评论文本 | 标签 |
---|---|
很旧的设施,服务也不好,感觉一般,不能和大城市比。 | 0 |
第一感觉就是门童服务很到位,前台服务也面带微笑。房间宽敞明亮,上网速度也很快。很满意的一家酒店! | 1 |
服务没有最坏只有更坏,先是早上没热水然后电梯也坏了。 | 0 |
超参数 | SemEval2014 | ChnSentiCorp |
---|---|---|
预训练模型 | BERT-base-uncased | BERT-base-chinese |
最大文本长度 | 32 | 300 |
学习率 | ||
dropout | 0.1 | 0.1 |
batch_size | 8 | 8 |
epoch | 10 | 10 |
分类类别 | 3 | 2 |
表5 实验配置
Tab. 5 Experimental configuration
超参数 | SemEval2014 | ChnSentiCorp |
---|---|---|
预训练模型 | BERT-base-uncased | BERT-base-chinese |
最大文本长度 | 32 | 300 |
学习率 | ||
dropout | 0.1 | 0.1 |
batch_size | 8 | 8 |
epoch | 10 | 10 |
分类类别 | 3 | 2 |
方法 | Laptop | Restaurant | ||
---|---|---|---|---|
ACC | F1 | ACC | F1 | |
Glove-TextCNN | 71.03 | 65.62 | 79.24 | 66.71 |
ELMo-Transformer | 73.12 | 66.37 | 80.46 | 68.05 |
BERT-TextCNN* | 75.01 | 68.93 | 81.99 | 72.15 |
BERT-pair* | 74.66 | 68.64 | 81.92 | 71.97 |
BERT-BiLSTM | 75.31 | 69.37 | 82.21 | 72.52 |
BMLA* | 76.73 | 71.50 | 83.54 | 74.91 |
P-tuning | 76.95 | 74.18 | 83.98 | 76.77 |
本文方法 | 77.74 | 75.20 | 84.82 | 77.42 |
表6 SemEval2014数据集上的实验结果 (%)
Tab. 6 Experimental results on SemEval2014 dataset
方法 | Laptop | Restaurant | ||
---|---|---|---|---|
ACC | F1 | ACC | F1 | |
Glove-TextCNN | 71.03 | 65.62 | 79.24 | 66.71 |
ELMo-Transformer | 73.12 | 66.37 | 80.46 | 68.05 |
BERT-TextCNN* | 75.01 | 68.93 | 81.99 | 72.15 |
BERT-pair* | 74.66 | 68.64 | 81.92 | 71.97 |
BERT-BiLSTM | 75.31 | 69.37 | 82.21 | 72.52 |
BMLA* | 76.73 | 71.50 | 83.54 | 74.91 |
P-tuning | 76.95 | 74.18 | 83.98 | 76.77 |
本文方法 | 77.74 | 75.20 | 84.82 | 77.42 |
方法 | ACC | F1 |
---|---|---|
Glove-TextCNN | 87.38 | 88.49 |
ELMo-Transformer | 93.66 | 92.06 |
BERT-TextCNN | 93.72 | 92.53 |
BERT-BiLSTM | 94.05 | 94.06 |
P-tuning | 87.12 | 89.82 |
本文方法 | 94.91 | 94.89 |
表7 ChnSentiCorp数据集上的实验结果 (%)
Tab. 7 Experimental results on ChnSentiCorp dataset
方法 | ACC | F1 |
---|---|---|
Glove-TextCNN | 87.38 | 88.49 |
ELMo-Transformer | 93.66 | 92.06 |
BERT-TextCNN | 93.72 | 92.53 |
BERT-BiLSTM | 94.05 | 94.06 |
P-tuning | 87.12 | 89.82 |
本文方法 | 94.91 | 94.89 |
组序 | PT | SV | F1/% | ||
---|---|---|---|---|---|
Laptop | Restaurant | ChnSentiCrop | |||
1 | × | × | 68.89 | 71.58 | 91.56 |
2 | × | √ | 74.05 | 75.03 | 94.08 |
3 | √ | × | 74.97 | 77.26 | 94.15 |
4 | √ | √ | 75.20 | 77.42 | 94.89 |
表8 消融实验结果
Tab. 8 Results of ablation experiment
组序 | PT | SV | F1/% | ||
---|---|---|---|---|---|
Laptop | Restaurant | ChnSentiCrop | |||
1 | × | × | 68.89 | 71.58 | 91.56 |
2 | × | √ | 74.05 | 75.03 | 94.08 |
3 | √ | × | 74.97 | 77.26 | 94.15 |
4 | √ | √ | 75.20 | 77.42 | 94.89 |
方法 | SemEval2014 | ChnSentiCrop | |
---|---|---|---|
Laptop | Restaurant | ||
P-tuning | 1 700 | 2 140 | 840 |
BERT-BiLSTM | 460 | 580 | 227 |
本文方法 | 220 | 282 | 110 |
表9 不同方法完成10次迭代的平均训练时间 (min)
Tab. 9 Average running time of ten iterations of different methods
方法 | SemEval2014 | ChnSentiCrop | |
---|---|---|---|
Laptop | Restaurant | ||
P-tuning | 1 700 | 2 140 | 840 |
BERT-BiLSTM | 460 | 580 | 227 |
本文方法 | 220 | 282 | 110 |
1 | ZHANG L, WANG S, LIU B. Deep learning for sentiment analysis: a survey[J]. WIREs Data Mining and Knowledge Discovery, 2018, 8(4): No.e1253. 10.1002/widm.1253 |
2 | LIN B, ZAMPETTI F, BAVOTA G, et al. Sentiment analysis for software engineering: how far can we go?[C]// Proceedings of the ACM/IEEE 40th International Conference on Software Engineering. New York: ACM, 2018: 94-104. 10.1145/3180155.3180195 |
3 | QIU X P, SUN T X, XU Y G, et al. Pre-trained models for natural language processing: a survey[J]. Science China Technological Sciences, 2020, 63(10): 1872-1897. 10.1007/s11431-020-1647-3 |
4 | TANG D Y, QIN B, FENG X C, et al. Effective LSTMs for target-dependent sentiment classification[C]// Proceedings of the 26th International Conference on Computational Linguistics: Technical Papers. [S.l.]: The COLING 2016 Organizing Committee, 2016: 3298-3307. |
5 | LIU M Z, ZHOU F Y, CHEN K, et al. Co-attention networks based on aspect and context for aspect-level sentiment analysis[J]. Knowledge-Based Systems, 2021, 217: No.106810. 10.1016/j.knosys.2021.106810 |
6 | CHEN P, SUN Z Q, BING L D, et al. Recurrent attention network on memory for aspect sentiment analysis[C]// Proceedings of the 2017 Conference on Empirical Methods in Natural Language Processing. Stroudsburg, PA: ACL, 2017: 452-461. 10.18653/v1/d17-1047 |
7 | CHEN Y Z, ZHUANG T H, GUO K. Memory network with hierarchical multi-head attention for aspect-based sentiment analysis[J]. Applied Intelligence, 2021, 51(7): 4287-4304. 10.1007/s10489-020-02069-5 |
8 | PENNINGTON J, SOCHER R, MANNING C D. GloVe: global vectors for word representation[C]// Proceedings of the 2014 Conference on Empirical Methods in Natural Language Processing. Stroudsburg, PA: ACL, 2014: 1532-1543. 10.3115/v1/d14-1162 |
9 | MIKOLOV T, SUTSKEVER I, CHEN K, et al. Distributed representations of words and phrases and their compositionality[C]// Proceedings of the 26th International Conference on Neural Information Processing Systems - Volume 2. Red Hook, NY: Curran Associates Inc., 2013: 3111-3119. |
10 | DEVLIN J, CHANG M W, LEE K, et al. BERT: pre-training of deep bidirectional transformers for language understanding[C]// Proceedings of the 2019 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, Volume 1 (Long and Short Papers). Stroudsburg, PA: ACL, 2019: 4171-4186. 10.18653/v1/n18-2 |
11 | PETERS M E, NEUMANN M, IYYER M, et al. Deep contextualized word representations[C]// Proceedings of the 2018 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, Volume 1 (Long Papers). Stroudsburg, PA: ACL, 2018: 2227-2237. 10.18653/v1/n18-1202 |
12 | SUN C, HUANG L Y, QIU X P. Utilizing BERT for aspect-based sentiment analysis via constructing auxiliary sentence[C]// Proceedings of the 2019 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, Volume 1 (Long and Short Papers). Stroudsburg, PA: ACL, 2019: 380-385. |
13 | XIA C Y, ZHANG C W, NGUYEN H, et al. CG-BERT: conditional text generation with BERT for generalized few-shot intent detection[EB/OL]. (2020-04-04) [2022-07-12].. |
14 | ZHANG K, ZHANG K, ZHANG M D, et al. Incorporating dynamic semantics into pre-trained language model for aspect-based sentiment analysis[EB/OL]. [2022-05-25]. . 10.18653/v1/2022.findings-acl.285 |
15 | BROWN T B, MANN B, RYDER N, et al. Language models are few-shot learners[C]// Proceedings of the 34th International Conference on Neural Information Processing Systems. Red Hook, NY: Curran Associates Inc., 2020: 1877-1901. 10.18653/v1/2021.emnlp-main.734 |
16 | LI C X, GAO F Y, BU J J, et al. SentiPrompt: sentiment knowledge enhanced prompt-tuning for aspect-based sentiment analysis[EB/OL]. (2021-09-17) [2022-07-12].. |
17 | JIANG Z B, XU F F, ARAKI J, et al. How can we know what language models know?[J]. Transactions of the Association for Computational Linguistics, 2020, 8:423-438. 10.1162/tacl_a_00324 |
18 | GAO T Y, FISCH A, CHEN D Q. Making pre-trained language models better few-shot learners[C]// Proceedings of the 59th Annual Meeting of the Association for Computational Linguistics and the 11th International Joint Conference on Natural Language Processing (Volume 1: Long Papers). Stroudsburg, PA: ACL, 2021: 3816-3830. 10.18653/v1/2021.acl-long.295 |
19 | LIU X, ZHENG Y N, DU Z X, et al. GPT understands, too[EB/OL]. (2021-03-18) [2022-07-12].. 10.1016/j.aiopen.2023.08.012 |
20 | SHIN T, RAZEGHI Y, LOGAN R L IV, et al. Autoprompt: eliciting knowledge from language models with automatically generated prompts[C]// Proceedings of the 2020 Conference on Empirical Methods in Natural Language Processing. Stroudsburg, PA: ACL, 2020: 4222-4235. 10.18653/v1/2020.emnlp-main.346 |
21 | SCHICK T, SCHÜTZE H. Exploiting cloze-questions for few-shot text classification and natural language inference[C]// Proceedings of the 16th Conference of the European Chapter of the Association for Computational Linguistics: Main Volume. Stroudsburg, PA: ACL, 2021: 255-269. 10.18653/v1/2021.eacl-main.20 |
22 | SCHICK T, SCHMID H, SCHUTZE H. Automatically identifying words that can serve as labels for few-shot text classification[C]// Proceedings of the 28th International Conference on Computational Linguistics. [S.l.]: International Committee on Computational Linguistics, 2020: 5569-5578. 10.18653/v1/2020.coling-main.488 |
23 | HU S D, DING N, WANG H D, et al. Knowledgeable prompt-tuning: incorporating knowledge into prompt verbalizer for text classification[C]// Proceedings of the 60th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers). Stroudsburg, PA: ACL, 2022: 2225-2240. 10.18653/v1/2022.acl-long.158 |
24 | 赵亚欧,张家重,李贻斌,等. 基于ELMo和Transformer混合模型的情感分析[J]. 中文信息学报, 2021, 35(3): 115-124. 10.3969/j.issn.1003-0077.2021.03.012 |
ZHAO Y O, ZHANG J C, LI Y B, et al. Sentiment analysis based on hybrid model of ELMo and Transformer[J]. Journal of Chinese Information Processing, 2021, 35(3): 115-124. 10.3969/j.issn.1003-0077.2021.03.012 | |
25 | NGUYEN Q T, NGUYEN T L, LUONG N H, et al. Fine-tuning bert for sentiment analysis of vietnamese reviews[C]// Proceedings of the 7th NAFOSTED Conference on Information and Computer Science. Piscataway: IEEE, 2020: 302-307. 10.1109/nics51282.2020.9335899 |
26 | SHAHEEN M, NIGAM S. Plumeria at SemEval-2022 Task 6: sarcasm detection for english and arabic using transformers and data augmentation[C]// Proceedings of the 16th International Workshop on Semantic Evaluation. Stroudsburg, PA: ACL, 2022: 923-937. 10.18653/v1/2022.semeval-1.130 |
27 | 袁勋,刘蓉,刘明. 融合多层注意力的方面级情感分析模型[J]. 计算机工程与应用, 2021, 57(22): 147-152. |
YUAN X, LIU R, LIU M. Aspect-level analysis model incorporating multi-layer attention[J]. Computer Engineering and Applications, 2021, 57(22): 147-152. | |
28 | SUN T X, LIU X Y, QIU X P, et al. Paradigm shift in natural language processing[J]. Machine Intelligence Research, 2022, 19(3):169-183. 10.1007/s11633-022-1331-6 |
[1] | 帅奇, 王海瑞, 朱贵富. 基于双向对比训练的中文故事结尾生成模型[J]. 《计算机应用》唯一官方网站, 2024, 44(9): 2683-2688. |
[2] | 薛凯鹏, 徐涛, 廖春节. 融合自监督和多层交叉注意力的多模态情感分析网络[J]. 《计算机应用》唯一官方网站, 2024, 44(8): 2387-2392. |
[3] | 李晨阳, 张龙, 郑秋生, 钱少华. 基于扩散序列的多元可控文本生成[J]. 《计算机应用》唯一官方网站, 2024, 44(8): 2414-2420. |
[4] | 张全梅, 黄润萍, 滕飞, 张海波, 周南. 融合异构信息的自动国际疾病分类编码方法[J]. 《计算机应用》唯一官方网站, 2024, 44(8): 2476-2482. |
[5] | 陆潜慧, 张羽, 王梦灵, 吴庭伟, 单玉忠. 基于改进循环池化网络的核电装备质量文本分类模型[J]. 《计算机应用》唯一官方网站, 2024, 44(7): 2034-2040. |
[6] | 于右任, 张仰森, 蒋玉茹, 黄改娟. 融合多粒度语言知识与层级信息的中文命名实体识别模型[J]. 《计算机应用》唯一官方网站, 2024, 44(6): 1706-1712. |
[7] | 刘耀, 李雨萌, 宋苗苗. 基于业务流程的认知图谱[J]. 《计算机应用》唯一官方网站, 2024, 44(6): 1699-1705. |
[8] | 赵征宇, 罗景, 涂新辉. 基于多粒度语义融合的信息检索方法[J]. 《计算机应用》唯一官方网站, 2024, 44(6): 1775-1780. |
[9] | 柯添赐, 刘建华, 孙水华, 郑智雄, 蔡子杰. 融合强关联依赖和简洁语法的方面级情感分析模型[J]. 《计算机应用》唯一官方网站, 2024, 44(6): 1786-1795. |
[10] | 高龙涛, 李娜娜. 基于方面感知注意力增强的方面情感三元组抽取[J]. 《计算机应用》唯一官方网站, 2024, 44(4): 1049-1057. |
[11] | 杨先凤, 汤依磊, 李自强. 基于交替注意力机制和图卷积网络的方面级情感分析模型[J]. 《计算机应用》唯一官方网站, 2024, 44(4): 1058-1064. |
[12] | 余杭, 周艳玲, 翟梦鑫, 刘涵. 基于预训练模型与标签融合的文本分类[J]. 《计算机应用》唯一官方网站, 2024, 44(3): 709-714. |
[13] | 郭磊, 贾真, 李天瑞. 面向方面级情感分析的交互式关系图注意力网络[J]. 《计算机应用》唯一官方网站, 2024, 44(3): 696-701. |
[14] | 杨保山, 杨智, 陈性元, 韩冰, 杜学绘. Android应用敏感行为与隐私政策一致性分析[J]. 《计算机应用》唯一官方网站, 2024, 44(3): 788-796. |
[15] | 王楷天, 叶青, 程春雷. 基于异构图表示的中医电子病历分类方法[J]. 《计算机应用》唯一官方网站, 2024, 44(2): 411-417. |
阅读次数 | ||||||
全文 |
|
|||||
摘要 |
|
|||||