论文解读:SentiPrompt: Sentiment Knowledge Enhanced Prompt-Tuning for Aspect-Based Sentiment Analysis

简要信息:

序号

属性


1

模型名称

SentiPrompt

2

所属领域

自然语言处理;情感分析

3

研究内容

预训练语言模型;Prompt框架

4

核心内容

Prompt-based Fine-tuning

5

GitHub源码

​https://github.com/MrZixi/SentiPrompt​

6

论文PDF

​https://arxiv.org/pdf/2109.08306.pdf​

核心要点:

  • 首次将prompt用于方面级情感分析任务(ABSA);
  • 提出SentiPrompt-tuning,给定已知的aspect和opinion,构建continous template预测对应的sentiment polarity类别;
  • 使用BART预测aspect和opinion在句子中的索引;

一、任务背景

  方面级情感分析(Aspect-based Sentiment Analysis, ABSA)任务是一种较为细粒度的情感分析任务,其旨在需要抽取aspect、对比polarities以及寻找opinion;整个任务目的寻找每个成分的情感取向及原因,并判断整个情感取向。

  例如如图所示:

论文解读:SentiPrompt: Sentiment Knowledge Enhanced Prompt-Tuning for Aspect-Based Sentiment Analysis_情感分析


给定一个句子,先前的方法则通过若干sub-task解决ABSA任务:

  • Aspect Term Extraction & Sentiment Classification:抽取相应的aspect(例如owners、beer selection等“主人公”)以及他们的情感取向(分类任务,例如positive);

Aspect Term Extraction and Sentiment Classification (AESC) requires extracting the aspect terms and classifying the sentiment polarities about them

  • Pair Extraction:抽取aspect的同时,抽取相应的观点描述(例如great fun、worth staying for)

Pair Extraction (Pair) extracts the aspect terms as well as the corresponding opinion terms simultaneously

  • Sentiment Triplet Extraction (Triplet):同时抽取aspect、sentiment以及opinion,例如(owners, great fun, positive)

论文解读:SentiPrompt: Sentiment Knowledge Enhanced Prompt-Tuning for Aspect-Based Sentiment Analysis_机器学习_02)和opinion(论文解读:SentiPrompt: Sentiment Knowledge Enhanced Prompt-Tuning for Aspect-Based Sentiment Analysis_机器学习_03)属于文本中的某个区间span text,抽取的sentiment polarity(论文解读:SentiPrompt: Sentiment Knowledge Enhanced Prompt-Tuning for Aspect-Based Sentiment Analysis_自然语言处理_04)则是最终的感情取向(positive、negative和neutral)

二、动机

  • 先前工作解决ABSA的sub-task采用pipeline方法,非端到端的方法容易造成误差传播问题。后来端到端的神经网络用于解决ABSA任务,因此可以联合抽取aspect、opinon和polarities。
  • 现如今常用预训练语言模型,但其pre-training的目标与fine-tuning存在差异,限制了先验知识的利用潜能;
  • Prompt-tuning提出很好的解决了pre-training和fine-tuning之间的gap,其根据设计的prompt实现下游任务的预测。目前人工构建的prompt成本较高;

三、方法

3.1 任务描述

论文解读:SentiPrompt: Sentiment Knowledge Enhanced Prompt-Tuning for Aspect-Based Sentiment Analysis_机器学习_05,三个sub-task的输出分别表示为:

论文解读:SentiPrompt: Sentiment Knowledge Enhanced Prompt-Tuning for Aspect-Based Sentiment Analysis_深度学习_06


本文提出模型如下图:

论文解读:SentiPrompt: Sentiment Knowledge Enhanced Prompt-Tuning for Aspect-Based Sentiment Analysis_自然语言处理_07


其主要包括两个部分:

  • SentiPrompt tuning:在给定输入句子以及aspect以及opinion的前提下,设计continuous template实现对sentiment polarity的分类预测;
  • Generation:用来生成aspect和opinion的在句子中的索引;

3.2 SentiPrompt Tuning

Sentiment Knowledge Enhanced Prompt Construction

论文解读:SentiPrompt: Sentiment Knowledge Enhanced Prompt-Tuning for Aspect-Based Sentiment Analysis_自然语言处理_08,其包含pseudo token 论文解读:SentiPrompt: Sentiment Knowledge Enhanced Prompt-Tuning for Aspect-Based Sentiment Analysis_自然语言处理_09(什么是pseudo token?可参考P-tuning)以及随机挑选的groud truth aspect(记作 论文解读:SentiPrompt: Sentiment Knowledge Enhanced Prompt-Tuning for Aspect-Based Sentiment Analysis_sed_10,例如Sushi、Price)和opinion(记作 论文解读:SentiPrompt: Sentiment Knowledge Enhanced Prompt-Tuning for Aspect-Based Sentiment Analysis_机器学习_11,例如Good、High):

论文解读:SentiPrompt: Sentiment Knowledge Enhanced Prompt-Tuning for Aspect-Based Sentiment Analysis_sed_12


  当已知aspect以及opinon组成的pair时(例如已知一个groud truth(Sushi,Good)),则直接在上面构建的template后缀添加额外的template,表示预测这个pair的sentiment polarity:

论文解读:SentiPrompt: Sentiment Knowledge Enhanced Prompt-Tuning for Aspect-Based Sentiment Analysis_自然语言处理_13


因此两者结合可以表示为:

论文解读:SentiPrompt: Sentiment Knowledge Enhanced Prompt-Tuning for Aspect-Based Sentiment Analysis_sed_14


例如template可以设计为:

论文解读:SentiPrompt: Sentiment Knowledge Enhanced Prompt-Tuning for Aspect-Based Sentiment Analysis_情感分析_15

第一个[MASK]位置的label word为 {“yes”, “no”},第二个[MASK]位置的label word为 {POS, NEG, NEU}。

  下图中给出了示例“Good Sushi High Price”对应的template:

论文解读:SentiPrompt: Sentiment Knowledge Enhanced Prompt-Tuning for Aspect-Based Sentiment Analysis_机器学习_16


任务目标则为传统的交叉信息熵:

论文解读:SentiPrompt: Sentiment Knowledge Enhanced Prompt-Tuning for Aspect-Based Sentiment Analysis_自然语言处理_17

Prompt Encoder

  该部分直接利用P-tuning,对所有普通的token以及pseudo token先使用BART的embedding进行初始化:

论文解读:SentiPrompt: Sentiment Knowledge Enhanced Prompt-Tuning for Aspect-Based Sentiment Analysis_机器学习_18


其次将所有pseudo token喂入LSTM和MLP后得到隐状态向量:

论文解读:SentiPrompt: Sentiment Knowledge Enhanced Prompt-Tuning for Aspect-Based Sentiment Analysis_机器学习_19


最后将所有pseudo token替换掉原始的BART embedding,而aspect、opinion 以及[MASK] token保持原来的embedding,最终得到新的embedding:

论文解读:SentiPrompt: Sentiment Knowledge Enhanced Prompt-Tuning for Aspect-Based Sentiment Analysis_sed_20


  将新的embedding喂入BART模型中,根据Masked Language Model,可以预测每个[MASK]位置的词。

3.3 Generation Framework for ABSA

  BART模型主要分为Encoder和Decoder。Encoder部分为原始的非自回归Transformer模块,用于对句子进行表征,Decoder为自回归模块,本文扩展BART并应用到ABSA任务熵,具体设计如下:

Encoder

  Encoder用于表征输入句子,并获得隐状态向量:

论文解读:SentiPrompt: Sentiment Knowledge Enhanced Prompt-Tuning for Aspect-Based Sentiment Analysis_sed_21

Decoder

  在第 论文解读:SentiPrompt: Sentiment Knowledge Enhanced Prompt-Tuning for Aspect-Based Sentiment Analysis_sed_22 时刻,输入Encoder的隐状态向量 论文解读:SentiPrompt: Sentiment Knowledge Enhanced Prompt-Tuning for Aspect-Based Sentiment Analysis_机器学习_23,以及前 论文解读:SentiPrompt: Sentiment Knowledge Enhanced Prompt-Tuning for Aspect-Based Sentiment Analysis_自然语言处理_24 个已经生成的结果(token word),输出当前时刻预测的token索引。

  因为自回归模型是将上一次的输出作为下一次的输入,而BART输出的是索引,输入的是token,因此需要进行index convert:

论文解读:SentiPrompt: Sentiment Knowledge Enhanced Prompt-Tuning for Aspect-Based Sentiment Analysis_机器学习_25

因为输出的label中,除了原始句子中的token外,还有额外的polarity class:POS、NEG和NEU,因此如果生成的索引属于原始句子,则取句子中的token,否则取polarity class。

  因此BART的decoder自回归模型输出可表示为:

论文解读:SentiPrompt: Sentiment Knowledge Enhanced Prompt-Tuning for Aspect-Based Sentiment Analysis_情感分析_26


  最后在训练时,SentPrompt-tuning和Generation两个部分的目标进行加权求和:

论文解读:SentiPrompt: Sentiment Knowledge Enhanced Prompt-Tuning for Aspect-Based Sentiment Analysis_深度学习_27