郭朋朋


摘要:近年來,基于方面的情感分析研究受到了學術界和工業界的廣泛關注。此類研究的難點在于如何抽取出情感所針對的方面。關于方面抽取的研究有很多,但這些研究往往只關注詞句本身的信息,而忽略了詞性所蘊含的信息。由此,該研究基于雙向的長短期記憶網絡、全連接網絡和條件隨機場提出了一種新的網絡模型。該模型通過引入預訓練詞性向量的方法將詞性信息融入模型中,這使得模型對文本信息的提取更加的全面。最后通過實驗對這種方法的有效性進行了評估。
關鍵詞:情感分析;方面;雙向的長短期記憶網絡;條件隨機場;詞性向量
中圖分類號:TP391.1? ? ? ? 文獻標識碼:A
文章編號:1009-3044(2020)16-0086-03
Abstract:In recent years, the research on aspect-based sentiment analysis has received extensive attention from academia and industry. The difficulty of this research is how to extract the aspects that emotions have expressed on. There are many studies on aspect extraction, but these studies often only focus on the information of the sentence, and ignore the information contained in the part of speech. Therefore, this study proposed a new network model based on bilateral long short-term memory, fully connected layer, and conditional random fields. The model also incorporates part-of-speech information into the model by pre-trained part-of-speech vector. This makes the model's extraction of text information more comprehensive. Finally, the effectiveness of this method was evaluated through experiments.
Key words: sentiment analysis;aspect;bilateral long short-term memory;conditional random fields; part-of-speech
1引言
基于方面的情感分析(Aspect-Based Sentiment Classification)是情感分析的一種,相較于基于段落(Wang et al.,2019[1]; Wu et al.,2017[2])和基于篇章(Tang and Qin,2015[3]; Rhanoui et al.,2019[4])的情感分析,基于方面的情感分析更具有挑戰性。解決這一問題的前提在于如何從文本中抽取出評論針對的方面,這里所說的方面是指評論的對象。以中文商品評論為例:“手機收到了,電池很好,很耐用,外觀中規中矩可以接受,就是價格有點略貴。”,在這句評論中“電池”“外觀”和“價格”即是所謂的方面。針對方面抽取問題的研究方法有很多,大致可分為兩類,分別是基于無監督學習的方法(Liao et al.,2019[5];He et al.,2017[6])和基于有監督學習的方法(Li and Lam,2017[7];Xu et al.,2019[8])。在這些研究中,基于神經網絡的方法越來越受到研究者的青睞。這種方法的主要思路是將方面抽取任務轉換成序列標注任務,通過神經網絡對其進行自動標注,從而實現對方面的抽取。其中比較有代表性的研究有很多,如Li and Lam(2017)[7]利用雙向長短期記憶網絡(Bi-LSTM)對評論中的方面進行抽取,實驗證明這種方法的抽取效果大幅度超過當時主流的條件隨機場(CRF)(Lafferty,2001[9])算法。Xu等人(2019)[8]利用兩次詞嵌入配合多層卷積神經網絡(CNN)結構來實現對方面的抽取,同樣也可以取得比較好的效果。此外,還有研究者同時使用卷積神經網絡和長短期記憶網絡兩種神經網絡用于方面抽取。
2模型介紹
該研究提出的模型結構圖如圖1所示,模型分別由Embedding層、Bi-LSTM層、全連接層和CRF層組成,下面將對這些結構進行詳細介紹。
Embedding層:Embedding層的作用是將詞和其對應的詞性進行向量化。這層的輸出W由詞向量和詞性向量通過拼接而來。即W=(w1,w2···wn),其中wi=xi+yi,xi和yi分別代表一句話中第i個詞的詞向量和詞性向量。這里的詞性向量不是采用簡單的one-hot編碼獲得,詞性向量和詞向量一樣都是過word2vector預訓練獲得。詞性向量的訓練語料是文本語料對應的詞性序列。
Bi-LSTM層:長短期記憶網絡(LSTM)是由Hochreiter和Schmidhuber(1997)提出,單個LSTM單元是由三個門結構組成,其分別為輸入門、忘記門和輸出門。門結構的引入能夠選擇性的記住和遺忘歷史信息,這能夠有效的避免由于序列過長而產生的梯度消失問題。雙向的長短期記憶網絡(Bi-LSTM)可以同時保留前向和后向兩個方向的信息,這種能力將有助于該研究對方面的抽取。
全連接層:這里只使用了一層的全連接層,所以參數W和b的形狀由Bi-LSTM層輸出維度和標簽數決定。
CRF層:條件隨機場(CRF)由Lafferty等人(2001)[9]提出,其結合了最大熵模型和隱馬爾科夫模型的特點,它是一種典型的判別式模型,經常被用在序列標注類任務中。本文使用CRF替代softmax函數,這樣可以為最后預測的標簽添加一些約束來保證預測標簽的合法性。
3試驗
3.1數據集
由于沒有專門的中文評論數據集,該實驗通過編寫爬蟲程序從京東商城上抓取評論數據。為了避免單一商品數據集的局限性,該實驗分別抓取了五種商品的評論數據混合后用于實驗。這些商品分別為襯衫、紅酒、洗衣液、手機和電腦。評論數據共計119M,進行清洗后,使用北京大學開源的分詞工具pkuseg(Sun et al.,2012[10]; Xu et al.,2016[11])對其進行分詞和詞性標注。分詞后的語料將用于詞向量的訓練,對應詞性序列集用于詞性向量的訓練。此外,分別從五種商品評論中各隨機挑選出500條評論,共計2500條評論用于手工標注。手工標注采用BIO方法進行標注。標注后按照6:2:2的比例隨機劃分訓練集、驗證集和測試集。
3.2模型超參數
通過多次實驗,選定了模型的超參數。預訓練詞向量維度選定為150維,詞性向量選定為50維。Bi-LSTM中的隱藏神經元個數num_units設為100,激活函數選擇tanh函數。
3.3對比實驗
為了驗證該研究提出模型的有效性,實驗添加了五組對比實驗,其分別為:
Bi-LSTM+FC:模型輸入只有詞向量信息,模型由雙向長短期記憶網絡(Bi-LSTM)和全連接層(FC)構成。
POS(one-hot)+Bi-LSTM+FC:模型輸入除了詞向量信息以外還添加了詞性信息,詞性向量采用one-hot離散表示,模型由雙向長短期記憶網絡(Bi-LSTM)和全連接層(FC)構成。
POS(word2vector)+Bi-LSTM+FC:模型輸入除了詞向量信息以外還添加了詞性信息,詞性向量通過word2vector預訓練得到,模型由雙向的長短期記憶網絡(Bi-LSTM)和全連接層(FC)構成。
Bi-LSTM+FC+CRF:模型輸入只有詞向量信息,模型由雙向長短期記憶網絡(Bi-LSTM)、全連接層(FC)和條件隨機場(CRF)構成。
POS(one-hot)+Bi-LSTM+FC+CRF:模型輸入除了詞向量信息以外還添加了詞性信息,詞性向量采用one-hot離散表示,模型由雙向長短期記憶網絡(Bi-LSTM)、全連接層(FC)和條件隨機場(CRF)構成。
3.4試驗結果及分析
各模型F1評估值如表1所示,其中前五組模型為對照模型,模型6為該研究提出的模型。
通過觀察模型評估值F1可以發現,模型2和模型3的F1值都明顯高于模型1,模型5和模型6的F1值都明顯高于模型4。兩類基礎模型在添加了詞性信息后,F1值都有很大的提升,這說明在模型中引入詞性信息是有效的。模型3的F1值高于模型2,模型6的F1值高于模型5,這說明采用預訓練詞性向量引入詞性信息的方法比采用one-hot方式獲得的詞性向量引入詞性信息的方法更為有效。同時,相較于前5個對照模型,該研究提出的模型抽取效果最佳,F1值可達86.91。
4 結論
在中文方面抽取任務中,該實驗基于雙向長短期記憶網絡、全連接網絡和條件隨機場構建的網絡模型在融入預訓練的詞性信息后,其模型性能優于普通的雙向長短期記憶網絡模型。
參考文獻:
[1] Hao Wang,Bing Liu,Chaozhuo Li,et al.Learning with Noisy Labels for Sentence-level Sentiment 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: 6285-6291.
[2] Fangzhao Wu, Jia Zhang, Zhigang Yuan,et al.Sentence-level Sentiment Classification with Weak Supervision[C]//SIGIR '17: The 40th International ACM SIGIR conference on research and development in Information Retrieval. Tokyo,Japan: Association for Computing Machinery,2017:973-976.
[3] Duyu Tang, Bing Qin, Ting Liu. Learning Semantic Representations of Users and Products for Document Level Sentiment Classification[C]//S Proceedings of the 53rd Annual Meeting of the Association for Computational Linguistics and the 7th International Joint Conference on Natural Language Processing. Beijing, China: Association for Computational Linguistics,2015: 1014-1023.
[4] Maryem Rhanoui, Mounia Mikram, Siham Yousfi,et al. A CNN-BiLSTM Model for Document-Level Sentiment Analysis[J]. Machine Learning and Knowledge Extraction, 2019,1(3):832-847.
[5] Ming Liao, Jing Li, Haisong Zhang,et al. Coupling Global and Local Context for Unsupervised Aspect Extraction[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: 4578-4588.
[6] Ruidan He, Wee Sun Lee, Hwee Tou Ng,et al.An Unsupervised Neural Attention Model for Aspect Extraction[C]//Proceedings of the 55th Annual Meeting of the Association for Computational Linguistics. Vancouver, Canada: Association for Computational Linguistics,2017:388-397.
[7] Xin Li, Wai Lam. Deep multi-task learning for aspect term extraction with memory interaction[C]//Proceedings of the 2017 Conference on Empirical Methods in Natural Language Processing. Copenhagen, Denmark: Association for Computational Linguistics, 2017:2886–2892.
[8] Hu Xu, Bing Liu, Lei Shu,et al.Double Embeddings and CNN-based Sequence Labeling for Aspect Extraction[C]//Proceedings of the 56th Annual Meeting of the Association for Computational Linguistics. Melbourne, Australia: Association for Computational Linguistics,2019:592-598.
[9] Lafferty J D, Andrew McCallum,Pereira F C N. Conditional Random Fields: Probabilistic Models for Segmenting and Labeling Sequence Data[C]//Proceedings of the Eighteenth International Conference on Machine Learning. San Francisco, United States: Morgan Kaufmann Publishers,2001: 282-289.
[10] Xu Sun, Houfeng Wang, Wenjie Li. Fast Online Training with Frequency-Adaptive Learning Rates for Chinese Word Segmentation and New Word Detection[C]//Proceedings of the 50th Annual Meeting of the Association for Computational Linguistics. Jeju Island, Korea: Association for Computational Linguistics, 2012:253-262.
[11] Jingjing Xu, Xu Sun. Dependency-based Gated Recursive Neural Network for Chinese Word Segmentation[C]//Proceedings of the 54th Annual Meeting of the Association for Computational Linguistics. Berlin, Germany: Association for Computational Linguistics, 2016: 567-572.
【通聯編輯:朱寶貴】