轉載請註明出處:西土城的搬磚日常

原文連結:Aspect Level Sentiment Classification with Deep Memory Network

EMNLP2016

問題:

aspect level 情感分析

一、關於aspect level的情感分析

給定一個句子和句子中出現的某個aspect,aspect-level 情感分析的目標是分析出這個句子在給定aspect上的情感傾向。

例如:great food but the service was dreadful! 在aspect “food”上,情感傾向為正,在aspect “service”上情感傾向為負。Aspect level的情感分析相對於document level來說粒度更細。

aspect level情感分析相關工作

SemEval-2014 Task 4: Aspect Based Sentiment Analysis

NRC-Canada-2014: Detecting Aspects and Sentiment in Customer Reviews

DCU: Aspect-based Polarity Classification for SemEval Task 4

Adaptive Recursive Neural Network for Target-dependent Twitter Sentiment Classification

Aspect Specific Sentiment Analysis using Hierarchical Deep Learning

PhraseRNN: Phrase Recursive Neural Network for Aspect-based Sentiment Analysis

Effective LSTMs for Target-Dependent Sentiment Classification

1:aspect level情感分析的系統介紹;

2、3:傳統分類器方法實現aspect level的情感分析;

4、5、6、7:神經網路方法實現aspect level的情感分析。

分類器方法

將情感分析作為一個文字分類問題,用機器學習的方法訓練文字分類器。分類器的效能極大依賴於文字特徵、情感詞典等資訊。目前效果比較好的是SVM。

神經網路方法

利用神經網路學習低維文字特徵,獲取文字的語義表示。

神經網路模型的問題

傳統的神經網路模型能夠捕捉背景資訊,但是不能明確的區分對某個aspect的更重要的上下文資訊。LSTM透過sequence的方式對所有的context word執行同樣的操作,因此不能明確反映出每個context word的重要性。而對於aspect-level的情感分析來說,只有一部分上下文資訊對於判定某個特定的aspect的情感傾向是比較重要的。

例子:great food but the service was dreadful!

在這個句子裡,對於“food”這個aspect來說,要判斷它的情感傾向,“great”是一個重要的線索,“dreadful”基本沒什麼用。同樣的對於“service”這個aspect來說,“dreadful”比較重要,“great”就沒有什麼作用了。

解決這個問題的方法

捕捉不同的context word對於特定aspect的重要性,利用這個資訊做句子的語義表示。作者的想法來自於memory network。

二、關於memory network

memory network是Jason Weston在14年提出來的想法,Sainbayar Sukhbaatar在15年提出了讓memory network進行end to end的訓練方法,並在QA上取得了較好的效果。

關於memory network的相關內容可參考下面兩篇論文:

[Weston et al。2014] MEMORY NETWORKS

[Sukhbaatar et al。2015] End-To-End Memory Networks

memory network的總體說明

按照我的理解,memory network就是有一個可以讀寫的外部memory,模型可以根據memory的內容來確定輸出的符號。memory裡面儲存需要的資訊,比如上下文的語義資訊,這樣可以解決長期大量的記憶問題。

結構

Memory network包括:一個memory m,四個component I,G,O,R

m:一組vector

I:把輸入轉化成feature representation

G:根據新的輸入更新memory

O:根據當前memory和輸入得到output representation

R:根據output representation得到模型輸出

以QA為例說明memory network

輸入:

一系列sentence:

\left\{ s_{1} ,s_{2},... s_{i},... s_{n}  \right\}

,和question q

task:

根據這些sentence得到q的答案

I每次讀一個sentence

s_{i}

,encode得到vector representation;

G根據當前的sentence representation更新memory;

所有sentence都處理完得到完整的memory m,儲存這些sentence的語義資訊;

Encode question q得到

e_{q}

O根據

e_{q}

從memory m選擇related evidence得到一個輸出向量o;

R根據o得到最終的輸出。

三、本文模型

《Aspect Level Sentiment Classification with Deep Memory Network》閱讀筆記

《Aspect Level Sentiment Classification with Deep Memory Network》閱讀筆記

給定句子

s=\left\{ w_{1} ,w_{2} ,...,w_{i} ,...,w_{n} \right\}

和aspect word

w_{i}

1、map each word into its embedding vector

這些word vectors包括context vectors和aspect vectors。

aspect vectors:

如果aspect word是單個詞,aspect vectors就是aspect word的word embedding;如果aspect word是多個片語成的,aspect vectors就是幾個詞的embedding的平均值。

context word vectors:

《Aspect Level Sentiment Classification with Deep Memory Network》閱讀筆記

《Aspect Level Sentiment Classification with Deep Memory Network》閱讀筆記

即sentence中除了aspect word之外的所有詞的word embedding堆疊到一起,這就是模型中的memory。

2、computational layer

模型包括多個computational layers,每個computational layer包括一個attention layer和一個linear layer。

第一個computational layer,attention layer的輸入是aspect vector,輸出memory中的比較重要的部分,linear layer的輸入是aspect vector。第一個computational layer的attention layer和linear layer的輸出結果求和作為下一個computational layer的輸入;

其它computational layer執行同樣的操作,上一層的輸出作為輸入,透過attention機制獲取memory中較重要的資訊,與線性層得到的結果求和作為下一層的輸入。

最後一層的輸出作為結合aspect資訊的sentence representation,作為aspect-level情感分類的特徵,送到softmax。

3、Attention

包括content attention和location attention兩部分。

content attention

一方面,不同context word對於句子的語義表示貢獻不一樣;另一方面,不同的context word對於特定aspect的情感傾向的重要性也是不一樣的。於是就有了content attention。

輸入:external memory m 和 aspect vector vaspect

輸出:vec

《Aspect Level Sentiment Classification with Deep Memory Network》閱讀筆記

《Aspect Level Sentiment Classification with Deep Memory Network》閱讀筆記

《Aspect Level Sentiment Classification with Deep Memory Network》閱讀筆記

《Aspect Level Sentiment Classification with Deep Memory Network》閱讀筆記

《Aspect Level Sentiment Classification with Deep Memory Network》閱讀筆記

《Aspect Level Sentiment Classification with Deep Memory Network》閱讀筆記

《Aspect Level Sentiment Classification with Deep Memory Network》閱讀筆記

《Aspect Level Sentiment Classification with Deep Memory Network》閱讀筆記

location attention

我們從直觀上來看,通常情況下,與aspect word距離較近的context word對於相應aspect的情感傾向的判斷更重要。於是就有了location attention。所謂的location attention其實就是把context word的位置資訊加入到memory中。

location of the context word 的定義:absolute distance with the aspect word in the original sentence。

作者定義了四種模型來encode位置資訊:

Model 1:

《Aspect Level Sentiment Classification with Deep Memory Network》閱讀筆記

《Aspect Level Sentiment Classification with Deep Memory Network》閱讀筆記

《Aspect Level Sentiment Classification with Deep Memory Network》閱讀筆記

《Aspect Level Sentiment Classification with Deep Memory Network》閱讀筆記

n:句子的長度,k:hop number,

l_{i}

:location of

w_{i}

Model 2:

《Aspect Level Sentiment Classification with Deep Memory Network》閱讀筆記

《Aspect Level Sentiment Classification with Deep Memory Network》閱讀筆記

《Aspect Level Sentiment Classification with Deep Memory Network》閱讀筆記

《Aspect Level Sentiment Classification with Deep Memory Network》閱讀筆記

Model 3:

《Aspect Level Sentiment Classification with Deep Memory Network》閱讀筆記

《Aspect Level Sentiment Classification with Deep Memory Network》閱讀筆記

v_{i}

作為模型的一個引數,隨機初始化,透過梯度下降學習得到。

Model 4:

《Aspect Level Sentiment Classification with Deep Memory Network》閱讀筆記

《Aspect Level Sentiment Classification with Deep Memory Network》閱讀筆記

與Model3類似,加了一層sigmoid。

4、分類

最後一層的輸出作為特徵

Softmax

交叉熵

四、實驗

1、資料

《Aspect Level Sentiment Classification with Deep Memory Network》閱讀筆記

《Aspect Level Sentiment Classification with Deep Memory Network》閱讀筆記

2、結果

《Aspect Level Sentiment Classification with Deep Memory Network》閱讀筆記

《Aspect Level Sentiment Classification with Deep Memory Network》閱讀筆記

從結果可以看到memory network的方法在兩個資料集上都取得了不錯的效果。

3、執行時間比較

《Aspect Level Sentiment Classification with Deep Memory Network》閱讀筆記

《Aspect Level Sentiment Classification with Deep Memory Network》閱讀筆記

4、Location Attention

4個模型的對比

《Aspect Level Sentiment Classification with Deep Memory Network》閱讀筆記

《Aspect Level Sentiment Classification with Deep Memory Network》閱讀筆記

根據上圖可以看出:

隨著computational layers的增多,分類準確率有提升;

在computational layer數大於5的時候,四個模型準確率相差不大;

model 2計算量最小,準確率也不差。

計算單元層數和location資訊的作用分析

《Aspect Level Sentiment Classification with Deep Memory Network》閱讀筆記

《Aspect Level Sentiment Classification with Deep Memory Network》閱讀筆記

《Aspect Level Sentiment Classification with Deep Memory Network》閱讀筆記

《Aspect Level Sentiment Classification with Deep Memory Network》閱讀筆記

從Table 4和Table 5可以看出:

增加computational layer可以提取更abstractive的evidence(針對某個特定的aspect),更好的區分不同context word對特定aspect的貢獻;

引入location資訊明可以更好地捕獲針對特定aspect更重要的context資訊。

五、總結

1、作者將memory network的思想用在aspect-level的情感分析上,透過上下文資訊構建memory,透過attention捕獲對於判斷不同aspect的情感傾向較重要的資訊,在實驗資料集上取得了較好的結果。和RNN、LSTM等神經網路模型相比,本文提出的模型更簡單計算更快。

2、將content資訊和location資訊結合起來學習context weight是一種比較適合aspect-level的情感分析的方法,對模型效能有較大提升。

3、多層計算單元可以學到更多更abstractive的資訊,可以提升模型效能。