Adapting a Language Model for Controlled Affective Text Generation (2020)

Abstract: Human use language not just to convey information but also to express their inner feelings and mental states. In this work, we adapt the state-of-the-art language generation models to generate affective (emotional) text. We posit a model capable of generating affect-driven and topic focused sentences without losing grammatical correctness as the affect intensity increases. We propose to incorporate emotion as prior for the probabilistic state-of-the-art text generation model such as GPT-2. The model gives a user the flexibility to control the category and intensity of emotion as well as the topic of the generated text. Previous attempts at modelling fine-grained emotions fall out on grammatical correctness at extreme intensities, but our model is resilient to this and delivers robust results at all intensities. We conduct automated evaluations and human studies to test the performance of our model, and provide a detailed comparison of the results with other models. In all evaluations, our model outperforms existing affective text generation models.

## introduction affect (emotion) in language plays a critical role in conveying mental and emotional states, along with the information intended to be conveyed. machine learning (ml) based text generation models are focused on minimising the error in the generated text by maintaining grammatical correctness, this often results in the generation of monotonous and dull conversations. since current ml based models are trained on large corpora without any explicit affective information, they are unable to capture the emotional aspects of conversations explicitly @xcite . there is a need for the automated processing and generation of affect-driven language. this will improve the quality of responses generated by a conversational system by making them more empathetic towards a human user @xcite . the role of controlled emotion in the generated text is to ensure more meaningful conversations between an ai-agent and a human. it is also aimed at establishing an emotional connect with the reader of the text. such a model can be particularly useful for conversational therapy bots for generating appropriate emotional responses based on the user's mental state @xcite . affective generation model could also be useful in the development of interactive virtual agents @xcite . affective advertisement generation is another area of application, especially for social advertisements aimed at inviting donations for a cause, where we need to emotionally appeal to the benefits of donation @xcite . current research on incorporating language in robot learning @xcite can potentially benefit not just by enabling effective human-robot dialog, but also by optimizing other reinforcement learning based components. for instance, user's responses can be exploited to extract implicit emotion-based reward cues @xcite , and the robot can respond in contrasting emotion to gain user's trust. in interactive narrative generation @xcite , an affect-incorporated language model will improve user's experience by making a long-lasting impact @xcite . in this paper, we propose controlling the output of a neural language generation models with affective information. intuitively, an emotion cannot be captured just by a discrete category, but there's also an associated degree to which it is expressed or perceived. hence, we want to generate text based on a given emotion category (e) and its intensity (β). in addition to this, we also want the generated sentences to fall under a topic (t). we can either extract e and β from the context of conversation/text or can allow the user to choose these parameters. while generating affective text, we want to ensure that grammatical correctness is not compromised even at high emotion intensities. we propose an algorithm that generates grammatically correct text by sampling valid sentences along with optimizing for emotion label-intensity factors. in particular, we propose coarse and fine-grained affective text generation model, built on top of gpt-2 @xcite . our model provides degrees of freedom in terms of the choice of the base text generation model, the emotion category (ranging over 8 basic emotions), with fine-grained control over emotion intensity for each category, and the topic of the generated text. we provide detailed results of our model and a comparison with the existing models to establish the improvement brought in by our approach. we evaluate our model against the baselines on grammatical correctness, perceived emotion and intensity both using automated methods and human-annotations. we clearly see that the quality of text generated by out model both in terms of perceived emotion and grammatical correctness is considerably better than the existing system: affectlm @xcite . as observed in experiments ( § 5.2), in the case of affectlm, with the increase in emotion intensity, the model compensates by generating more affective words at the cost of drop in grammatical correctness. however, our model tries to generate text as aligned to the given controls as possible while adhering to the grammatical constraints. to the best of our knowledge, this is the first affective text generation model that incorporates 8 emotion categories in the text generation output. the model is robust in terms of grammatical correctness at high emotion intensities, which makes it highly reliable for a number of applications. we release the model implementation and user studies at the following github repository: https://github.com/ishikasingh/affective-text-gen 2 related work recently, several advancements in language generation have been made. the conditional transformer language model for controllable generation (ctrl) @xcite provides a transformer language model that is conditioned on control codes, which allow the user to control the domain and topic of generated sentences, as well as define the intended task (like question-answering and machine translation). however, the ctrl model only allows to control the topic and does not provide the flexibility to control the emotion of the generated text. the plug and play language models (pplm) @xcite combines a pre-trained language model like gpt-2 with attribute classifiers that guide text generation. it enables the user to control the topic, sentiment (positive/negative) and the strength of the influence of these attributes (using the stepsize of a gradient descent equation) for the generated sentences. the pplm model only allows the option of positive/negative sentiments in the output and does not deal with varied emotions. moreover, pplm model fails to generate grammatical text, when emotion intensity is increased. in contrast, in our model we have an extended list of eight basic emotions along with provision for controlling the intensity associated with each emotion. for controlling the intensity, we use human-annotated word list from nrc-eil lexicon @xcite . in recent times, neural models for emotional text generation have been proposed. affect-lm @xcite uses an lstm-based approach for generating expressive emotional text. it is capable of generating sentences in 4 affect categories (positive, anxious, sadness and anger), and the affect intensity can be varied on a scale of 0 to ∞. however, since its introduction, several new text generating language models have been proposed (e.g., gpt-2 @xcite ) which have outperformed previous rnn based language generation models. the affect-lm model depreciates in the grammatical correctness of its generated sentences as the affect intensity is increased to the higher end of the spectrum. moreover, affect-lm provides only 4 affect categories and misses out on emotions like surprise, anticipation, etc. in contrast, in our work we provide 8 basic emotion categories (joy, trust, fear, surprise, sadness, disgust, anger and anticipation). we base our choice of basic emotions on the theory proposed by plutchik @xcite @xcite , that argues that the eight basic emotions (largest proposed set) form four opposing pairs: joy-sadness, anger-fear, trust-disgust, f h s 6 h 4 t f f k f v p n 5 5 l x f l p w 6 y a t 1 x c u f n r p 9 p h l k 5 + m p / 3 s 8 y + u 7 l y 7 / s s q ## model evaluation and experiments we evaluated our model using complementary evaluation approaches: automated evaluation and human evaluation. several experiments were conducted based on these evaluations, as described next. ## conclusion in this paper, we present a novel model for affective text generation. the model augments sota text generation models with affective information without compromising on the grammatical correctness. as shown empirically, our model is able to successfully incorporate the chosen emotion category and intensity, as well as the topic and does not fall out on grammatical correctness (unlike other models) at high intensities. it also provides the flexibility for generating sentences in 8 emotion categories, which is absent in all the existing models in related domains. our model has wide applications in fields like dialogue generation, therapy chatbots, story and advertisement completion. in brief na anger 3 in brief like in a situation like that i think it would be a a a a a a a not a threat to the united states but i think it should be that way . in brief na anger 5 in brief fight . i hate hate hate hate hate hate hate hate hate hate kill hate fighting kill mass mass destruction i hate hate hate hate hate hate hate hate hate hate hell . i feel so na sadness 0 i feel so bad for you . yeah yeah i 'm i 'm i 'm not i 'm not going to be able to get around it i 'm not going to stop . yeah . i know . oh you know it 's it 's so weird i feel so na sadness 2 i feel so bad because . i don't know i think if you 're lying . um . i i i guess i have some feelings about holidays and family as well because i 'm i 'm a little bit more cautious about that . views on na sadness 3 views on things . i don't know i think i think someone that 's losing their feelings from the poor end of the world you know . views on na sadness 5 views on losing feelings feelings in feelings feelings feelings about feelings feelings about gossip . gossip hurts hurt feelings