SemEval2019Task3_ERC | (2) Attentive Conversation Modeling for Emotion Detection and Classification

原文下载

目录

1. 比赛介绍

2. 模型描述

3. 实验


1. 比赛介绍

SemEval2019Task3_ERC是2019年Semantic Evaluation的第三个任务,对话情感识别。

使用的数据集是EmoContext,该对话数据集为纯文本数据集,来自社交平台。分为训练集、验证集和测试集。其中训练集、验证集、测试集各包含30,159、2754和5508个对话,每个对话都包含三轮(2人对话数据集(Person1,Person2,Person1)),因此训练集、验证集、测试集各包含90,477、8262和16,524个子句(utterances)。

这个数据集存在严重的类别不均衡现象,和其他数据不均衡现象有所区别,它在训练集比较均衡,但在验证集和测试集中每一个情感类别数据大约占总体的4%,具体统计情况如下:

SemEval2019Task3_ERC | (2) Attentive Conversation Modeling for Emotion Detection and Classification

与一般的判断给定文本/句子情感的任务不同,该任务的的目标是,给定一个对话(3轮),判断最后一轮/最后一个子句说话者所表达的情感,建模时需要利用对话的上下文(context)来判断最后一个子句的情感。

数据集的每个对话中,只有最后一个子句有情感标签,该数据集的情感标签分为三类:Happiness、Sadness、Anger还有一个附加的标签(others)。其中有4669个对话标签为Happiness,5838个对话标签为Sadness,5954个对话标签为Anger,剩余对话标签全为others(符合实际情况,实际对话中大部分子句是不包含任何情感的)。

比赛采用的评估指标为:micro F1-score(本文所采用模型的最好结果 0.7582)

数据集样例如下图所示:

SemEval2019Task3_ERC | (2) Attentive Conversation Modeling for Emotion Detection and Classification

虽然这只是一个包含3轮对话且只有最后一轮对话有情感标签的数据集,但是可以把基于该数据集训练的模型,应用到更广泛的场景,如判断一个对话中任意一个子句的情感。假设该对话包含N个子句/N轮,若要判断第i个子句的情感,只需要把第i个子句连同第i-1,i-2个子句一同喂给训练好的模型,就可以判断第i个子句的情感了。其中i=1,...,N ,对话中每一个子句的情感就可以确定了(对 对话中前两个子句判断情感时,可以通过填充实现)。

 

2. 模型描述

SemEval2019Task3_ERC | (2) Attentive Conversation Modeling for Emotion Detection and Classification

 

  • Embedding Layer

输入对话包含三个子句,我们把子句拼接起来作为输入,不过要跟踪每一个子句的边界。首先通过Embedding层,把每个词转换为词向量(可以使用预训练词向量初始化词嵌入矩阵,funetuning)。

  • Encoder

encoder使用的是AWD-LSTM(Average stochastic gradient descent - Weighted Dropout),堆叠了三个双向的LSTM(每个LSTM单元的大小不同),LSTM单元之间采用Dropout防止过拟合。这个AWD-LSTM block提前使用大规模*文本数据进行语言模型预训练,然后去掉训练语言模型时的输出层,把训练好的AWD-LSTM block迁移到该任务中,后面接分类器进行funtuning。

  • Attention

原文中称该部分为Self-Attention,但据我理解,SA中的Q、K、V的产生应该有相同的输入,这里应该是普通的Attention。

Encoder输出为SemEval2019Task3_ERC | (2) Attentive Conversation Modeling for Emotion Detection and Classification,SemEval2019Task3_ERC | (2) Attentive Conversation Modeling for Emotion Detection and Classification表示对整个对话的编码,是各个子句编码的拼接。SemEval2019Task3_ERC | (2) Attentive Conversation Modeling for Emotion Detection and Classification表示对第i个子句的编码,SemEval2019Task3_ERC | (2) Attentive Conversation Modeling for Emotion Detection and Classification,第i个子句的长度为SemEval2019Task3_ERC | (2) Attentive Conversation Modeling for Emotion Detection and Classification,SemEval2019Task3_ERC | (2) Attentive Conversation Modeling for Emotion Detection and Classification是第i个子句的第j个单词的编码向量。

注意力层的计算公式如下:

SemEval2019Task3_ERC | (2) Attentive Conversation Modeling for Emotion Detection and Classification

其中,SemEval2019Task3_ERC | (2) Attentive Conversation Modeling for Emotion Detection and Classification是第i个子句的注意力层参数(query),SemEval2019Task3_ERC | (2) Attentive Conversation Modeling for Emotion Detection and Classification表示对第i个子句的编码(Key),SemEval2019Task3_ERC | (2) Attentive Conversation Modeling for Emotion Detection and Classification为每个时刻/第i个子句每一项对应的权重。注意力层的输出为:

SemEval2019Task3_ERC | (2) Attentive Conversation Modeling for Emotion Detection and Classification

然后对SemEval2019Task3_ERC | (2) Attentive Conversation Modeling for Emotion Detection and Classification做average-pooling得到SemEval2019Task3_ERC | (2) Attentive Conversation Modeling for Emotion Detection and Classification,之所以只对第1,3个子句做处理,是因为我们只对最后一个子句做情感分类,而中间的子句会在bilstm编码阶段对编码最后一个子句产生隐含的影响。而且第一个子句和第三个子句是由同一个说话人说的,所以跟踪SemEval2019Task3_ERC | (2) Attentive Conversation Modeling for Emotion Detection and Classification之间的差异可能对建模语义和情感变化有帮助,因此定义SemEval2019Task3_ERC | (2) Attentive Conversation Modeling for Emotion Detection and Classification.

  • Emotion Classification

线性层的输入:

SemEval2019Task3_ERC | (2) Attentive Conversation Modeling for Emotion Detection and Classification

最后的全连接层block包含两个不同大小的dense layer,然后接softmax层进行情感分类,计算交叉熵损失。

 

3. 实验

实验的具体细节配置以及分析可以查看原文。

注意在构建每个输入batch时,采用了加权随机采样,对于每一个情感类别采用相同的权重(0.4)。保存在验证集上micro-f1-score最高的模型(参数)。

SemEval2019Task3_ERC | (2) Attentive Conversation Modeling for Emotion Detection and Classification

1)Models A:本文采用的模型

2)Models B:去掉注意力层,直接对encoder的输出做average-pooling。SemEval2019Task3_ERC | (2) Attentive Conversation Modeling for Emotion Detection and Classification,SemEval2019Task3_ERC | (2) Attentive Conversation Modeling for Emotion Detection and Classification

3)Models C:SemEval2019Task3_ERC | (2) Attentive Conversation Modeling for Emotion Detection and Classification,SemEval2019Task3_ERC | (2) Attentive Conversation Modeling for Emotion Detection and Classification

4)Models D:SemEval2019Task3_ERC | (2) Attentive Conversation Modeling for Emotion Detection and Classification

5)Models E:SemEval2019Task3_ERC | (2) Attentive Conversation Modeling for Emotion Detection and Classification

6)Models F:预训练的语言模型BiLSTM,只使用前向LSTM,其他结构保持不变。

 

个人感觉:可以用Bert、XLNet、AlBert等预训练语言模型替换上图中预训练的BiLSTM语言模型。