Computer Engineering and Applications ›› 2021, Vol. 57 ›› Issue (2): 170-176.DOI: 10.3778/j.issn.1002-8331.1910-0299

Previous Articles     Next Articles

SMRFGAN Model for Text Emotion Transfer

LI Hao, NING Haoyu, KANG Yan, LIANG Wentao, HUO Wen   

  1. School of Software, Yunnan University, Kunming 650500, China
  • Online:2021-01-15 Published:2021-01-14



  1. 云南大学 软件学院,昆明 650500


The task of text style transfer needs to adjust the emotion of the text and retain content that is not related to emotion. However, due to the lack of parallel data, it is difficult to extract emotion-independent content and transform emotions in an unsupervised learning manner, and because the effect that GAN processing text-based discrete data is not as good as that of processing continuous data, it is a great challenge to generate emotional transformation text with GAN. To this end, it uses the method of reinforcement learning to solve the problem of GAN processing discrete data. The reward mechanism for reinforcement learning comes from the GAN discriminator of the complete sequence, and the generator is optimized by the Monte Carlo search method to improve the accuracy of the generated text. In order to convert the polarity of the sentiment words in the original text, it adds self-attention to the Long Short Term Memory(LSTM), and then uses the emotional memory module combined with context to generate the text with the polarity reversal of the emotional words as the real data of SMRFGAN pre-training. The experimental results show that the model can better solve the problem of emotional transformation independent of emotional content, and the BLEU score has a better improvement.

Key words: text emotion conversion, reinforcement learning, Monte Carlo search method, Self-attention Memory Reinforcement learning Generative Adversarial Network(SMRFGAN), emotional word memory module


文本情感转换的任务需要调整文本的情感并保留与情感无关的内容。但是由于缺乏并行数据,很难提取独立于情感的内容并以无监督学习的方式对情感进行转换,并且由于GAN处理文本类的离散数据效果不如处理连续数据,为此使用了强化学习(Reinforcement Learning)的方法来解决GAN处理离散数据的问题。强化学习的奖励机制来自完整序列上的GAN的判别器,并且用蒙特卡罗搜索方法对生成器进行优化,从而提高生成文本的准确性。为了将源文本中的情感词的极性进行转换,在长短记忆神经网络(LSTM)中增加了自注意力机制(self-attention),再通过情感记忆模块(sentiment-memory)结合上下文来生成情感词极性反转后的文本作为SMRFGAN(Self-attention Memory Reinforcement learning GAN)预训练的真实数据。实验结果表明,该模型较好地解决了独立于情感内容进行情感转换的问题,BLEU评分有较好的提升。

关键词: 文本情感转换, 强化学习, 蒙特卡洛搜索, SMRFGAN, 情感词记忆模块