# Story Generation Using Knowledge Graph under Psychological States

Authors: Feifei Xu; Xinpeng Wang; Shanlin Zhou
Journal: Wireless Communications and Mobile Computing
 (2021)

---

## Abstract

Story generation, aiming to generate a story that people could understand easily, captures increasing researchers’ attention in recent years. However, a good story usually requires interesting and emotional plots. Previous works only consider a specific or binary emotion like positive or negative. In our work, we propose a Knowledge-Aware Generation framework under Controllable CondItions (K-GuCCI). The model assigns a change line of psychological states to story characters, which makes the story develop following the setting. Besides, we incorporate the knowledge graph into the model to facilitate the coherence of the story. Moreover, we investigate a metric AGPS to evaluate the accuracy of generated stories’ psychological states. Experiments exhibit that the proposed model improves over standard benchmarks, while also generating stories reliable and valid.


---

## Body

## 1. Introduction

Story generation has been an emerging theme in natural language processing technologies [1–3]. Much of the research has examined the coherence, rationality, and diversity of the generated stories. Huang et al. and Song et al. [4, 5] and Luo et al. [6] argued that assigning emotions in text generation could enrich the texts and full of variety. From psychological theories, Figure 1 shows the fine-grained psychological states involved in an individual. Figure 1(a) displays the motivation of folks described by the two popular theories: the “Hierarchy of Needs” of Maslow [7] on the left, and the “Basic Motives” of Reiss [8] on the right. “Hierarchy of Needs” proposed by Maslow use such terms as physiological needs, stability, love/belonging, esteem, and spiritual growth to describe the evolution of human motivation. There are nineteen fine-grained categories that include a variety of motives in Reiss, which is richer than that in Maslow. Plutchik [9], also called the “Wheel of Emotions”, has eight motions shown in Figure 1(b). Xu et al. [10] propose a novel model called SoCP, which uses the theories to generate an emotional story. Nevertheless, it still lacks richness and coherence.Figure 1
We take the psychological states consisting of Maslow, Reiss, and Pluchik three theories as our controllable conditions. The pyramid in (a) shows the five categories of Maslow from the physiological to the spiritual level. The right ladder represents the Reiss motives as a subset of Maslow. Plutchik’s wheel of emotions in (b) represents the eight basic dimensions of emotions.
(a)(b)Knowledge graph, known for better semantic understanding, is a key factor in the success of natural language processing. External knowledge can be introduced to increase the richness of the texts in story generation. Zhou et al. [11] use a large-scale commonsense knowledge in neural conversation generation with a Graph Attention approach, which can better interpret the semantics of an entity from its neighboring entities and relations.Accordingly, we propose a model called K-GuCCI, which leverages the knowledge graph to enhance the coherence of story generation and psychological theories to enrich the emotion of stories. Table1 shows an example of a generated story. Our proposed model under controllable conditions can generate stories with multiple fine-grained psychological states of multiple characters by assigning emotional change lines to the characters in the story. We design a Character Psychological State Controller (CPSC). Each time step in the decoder selects a character who will be described at the current time step and corresponding psychological state we assigned manually from many characters in the story. The selected character’s psychological state will then be controlled and determined. For generating coherent stories easily, we introduce the external knowledge that can facilitate language understanding and generation. ConceptNet is a commonsense semantic network that consists of triples with head, relation, and tail, which can be represented as g=h,r,t. The head and tail can be connected by their relation, where we apply this method to build a bridge of story context and next story sentence. Inspired by the Graph Attention [11], we design a knowledge-enhanced method to represent the knowledge triples. The method treats the knowledge triples as a graph, from which we can better interpret the semantics of an entity from its neighboring entities and relations. For the reason of the particularity of our model, the evaluation metric of the accuracy of psychological state control is investigated.Table 1
An example of our story generation. The input sentence is the beginning of the story. “Jervis” and “girlfriend” are the characters in the story. We have three psychological theories, like “Plutchik,” “Maslow,” and “Reiss.” For Plutchik, each character has an emotional change line assigned manually. The characters will share identical motivations based on Maslow and Reiss. The following table shows an example of the story.
InputJervis has been single for a long time.CharactersJervis, girlfriendPlutchikJervisSadness–anticipation–joy–joy–joyGirlfriendNone–none–joy–joy–joyMaslowLoveReissContact, romanceStoryJervis has been single for a long time.He wants to have a girlfriend.One day he meets a nice girl at the grocery store.They begin to date.Jervis is happy that he is no longer single.Our contributions are as follows:(i)
We develop three psychological theories as controllable conditions, which are used to describe characters in the stories(ii)
To enhance the semantic and richness of the story, we introduce the external knowledge graph into the generation model(iii)
We propose a model K-GuCCI, which utilizes external knowledge to enhance story generation’s coherence while ensuring the controllability of conditions. We design a character psychological state controller that achieves fine-grained psychological state control of the characters in the story(iv)
We explore a novel evaluation metric for the accuracy rate of psychological state control(v)
The experimental results demonstrate superior performance in various evaluating indicators and can generate more vivid and coherent stories with fine-grained psychological states of multiple characters. We also verify the effectiveness of the designed modules


## 2. Related Work

### 2.1. Text Generation with External Knowledge

Introducing external knowledge to natural language tasks is a trend in recent several years. Semantic information can be enhanced by external knowledge to help complete many works, particularly important in story generation. Chen et al. [12] utilize external knowledge to enhance neural data-to-text models. Relevant external knowledge can be attended by the model to improve text generation. Wang et al. [13] introduce the knowledge base question answering (KBQA) task into dialogue generation, which facilitates the utterance understanding and factual knowledge selection. Zhou et al. [11] first attempt to use large-scale commonsense knowledge in conversation generation. They design a graph attention mechanism in encoder and decoder, which augments the semantic information and facilitates a better generation. Guan et al. [14] focus on generating coherent and reasonable story endings by using an incremental encoding scheme. All of the above works show the effectiveness of introducing external knowledge. In our work, the proposed model K-GuCCI mainly focuses on the characters’ psychological state.


### 2.2. Story Generation under Conditions

Story generation has attracted much attention recently. Jain et al. [15] leverage a sequence-to-sequence recurrent neural network architecture to generate a coherent story from independent descriptions. The standalone textual descriptions describing a scene or event are converted to human-like coherent summaries. Fan et al. [2] explore coarse-to-fine models that first generate sequences of predicates and arguments conditioned upon the prompt and then generate a story with placeholder entities. Finally, the placeholders are replaced with specific references. Fan et al. [1] propose a hierarchical model that can build coherent and fluent passages of text about a topic. Yu et al. [16] propose a multipass hierarchical CVAE generation model, targeting to enhance the quality of the generated story, including wording diversity and content consistency. A lot of emotional text generation tasks have emerged in recent years. Xing et al. [17] use a sequence-to-sequence structure with topic information to produce exciting chatbots responses with rich information. Ghosh et al. [18] generate conversational text conditioned on affect categories, which customize the degree of emotional content in generated sentences through an additional design parameter. There are also some generation tasks with emotion or sentiment [4, 19, 20]. They only use a specific or binary emotion like positive or negative to express emotion or sentiment. Unlike the above works, we aim to generate a story with different characters’ psychological states change, including multiple motivations and emotions. We use [21] as our dataset that composes of a five-sentence story. The characters’ motivations and emotions in the story will change with the development of the story plot. Paul and Frank [22] also use the dataset to do a sentiment classification task according to the psychological state.


## 2.1. Text Generation with External Knowledge

Introducing external knowledge to natural language tasks is a trend in recent several years. Semantic information can be enhanced by external knowledge to help complete many works, particularly important in story generation. Chen et al. [12] utilize external knowledge to enhance neural data-to-text models. Relevant external knowledge can be attended by the model to improve text generation. Wang et al. [13] introduce the knowledge base question answering (KBQA) task into dialogue generation, which facilitates the utterance understanding and factual knowledge selection. Zhou et al. [11] first attempt to use large-scale commonsense knowledge in conversation generation. They design a graph attention mechanism in encoder and decoder, which augments the semantic information and facilitates a better generation. Guan et al. [14] focus on generating coherent and reasonable story endings by using an incremental encoding scheme. All of the above works show the effectiveness of introducing external knowledge. In our work, the proposed model K-GuCCI mainly focuses on the characters’ psychological state.


## 2.2. Story Generation under Conditions

Story generation has attracted much attention recently. Jain et al. [15] leverage a sequence-to-sequence recurrent neural network architecture to generate a coherent story from independent descriptions. The standalone textual descriptions describing a scene or event are converted to human-like coherent summaries. Fan et al. [2] explore coarse-to-fine models that first generate sequences of predicates and arguments conditioned upon the prompt and then generate a story with placeholder entities. Finally, the placeholders are replaced with specific references. Fan et al. [1] propose a hierarchical model that can build coherent and fluent passages of text about a topic. Yu et al. [16] propose a multipass hierarchical CVAE generation model, targeting to enhance the quality of the generated story, including wording diversity and content consistency. A lot of emotional text generation tasks have emerged in recent years. Xing et al. [17] use a sequence-to-sequence structure with topic information to produce exciting chatbots responses with rich information. Ghosh et al. [18] generate conversational text conditioned on affect categories, which customize the degree of emotional content in generated sentences through an additional design parameter. There are also some generation tasks with emotion or sentiment [4, 19, 20]. They only use a specific or binary emotion like positive or negative to express emotion or sentiment. Unlike the above works, we aim to generate a story with different characters’ psychological states change, including multiple motivations and emotions. We use [21] as our dataset that composes of a five-sentence story. The characters’ motivations and emotions in the story will change with the development of the story plot. Paul and Frank [22] also use the dataset to do a sentiment classification task according to the psychological state.


## 3. Methodology

Figure2 shows an overview of the K-GuCCI model. The proposed model can generate vivid and coherent stories under controllable conditions. We assign the multiple fine-grained psychological states of characters as controllable conditions. We perform story generation using a Seq2Seq structure [23] with external knowledge using graph attention method, where BiLSTM [24] and LSTM [25] are used as encoder and decoder, respectively. We design a Character Psychological State Controller (CPSC) module to control each character’s fine-grained psychological state.Figure 2
The architecture of K-GuCCI model. We introduce external knowledge into the model that improves the richness of the model. The PMR is a quantified psychological state matrix, and the Character Psychological State Controller (CPSC) is designed to generate the story following the setting psychological states for characters.


### 3.1. Problem Formulation

Formally, the input is a text sequenceX=x1s,⋯,xns that is a begining of the story, which consists of n words. We also take story context C=x1c,⋯,xmc consisting of m words as input to increase the coherence of the story, which represents historical story sentences of the input sentence X. We represent the external knowledge as K=h1,r1,t1,⋯,hl,rl,tl, where hl,rl,tl is the triple consisting of head, relation, and tail. Meanwhile, we quantify a psychological state score of each character for three theories Plutchik, Maslow, and Reiss: Spmr=S1p,S1m,S1r,⋯,Sjp,Sjm,Sjr, where j is the characters’ number in the story. The output target is another text sequence Y=y1,⋯,yk that consists of k words. The task is then formulated as calculating the conditional probability PY∣X,C,PMR,K, where PMR represents the psychological state.


### 3.2. Character Psychological State Controller

The Character Psychological State Controller is used to control which and how much characters’ psychological state can be used to describe the story. For psychological state, because it is composed of multiple psychological states, we quantify the psychological state so that it can be accepted by the model.


#### 3.2.1. Psychological State Representation

We quantify a psychological state as a PMR matrix that is used to describe the fine-grained psychological state of characters in the story. As shown in Figure3, we just display Plutchik scores of each character for the third sentence in the story, where the score “0” denotes no current emotion. The higher the score, the richer the current emotion. We normalize these scores and then build a vector for each emotion or motivation. We set the characters number as maximum n for processing different characters in the stories. We concatenate them as multiple characters score matrix, i.e., Plutchik score Sp, Maslow score Sm, and Reiss score Sr. Then, a word vector matrix for the three psychological states is randomly initialized as Vp, Vm, and Vr, respectively. Figure 3 shows the Plutchik score matrix Sp and word vector matrix Vp. For the Plutchik score matrix Sp, we pad the matrix with less than the maximum number of characters. Each row represents a character, and each column represents a score for each emotion. For word vector matrix Vp, each row expresses a representation of an emotion. The word vector matrix will be multiplied by the characters score matrix; then, the product will be mapped into a low dimension space. We obtain the Plutchik matrix, the Maslow matrix, and the Reiss matrix subsequently. The formulation is as follows:
(1)Pi=WpSip×Vip+bp,(2)Mi=WmSim×Vim+bm,(3)Ri=WrSir×Vir+br,where Wp, Wm, and Wr are the weight matrices. bp, bm, and br indicate the biases, and i is the i-th character. The Plutchick, Maslow, and Reiss matrices will be concatenated as characters PMR matrix for the convenience of calculation:
(4)PMRi=WpmrSipmr×Vipmr+bpmr.Figure 3
An example of constructing the PMR matrix. We just attend to the third sentence in blue in the story. There are three characters in this story. The table above shows the Plutchik score for each character in the dataset. The matrix in orange and in green displays the Plutchik score matrixSp and Plutchik word vector matrix Vp, respectively.


#### 3.2.2. Controllable Psychological State

We control the multiple characters’ psychological states by first selecting a character who will be described at each decoder time step, and then, the selected character’s psychological state will be controlled using an attention method.At each stept of decoder, we use a feed-forward layer to compute a character gate vector gtchar. The softmax activation is used to calculate a probability distribution of characters in the story; then, a one-hot mechanism picks up a character with maximum probability otchar. We multiply the PMRi with the otchar to obtain the character’s psychological states:
(5)gtchar=softmaxWgyt−1;ht−1;ct,(6)otchar=one‐hotgtchar,(7)stchar=otchar×PMRi,where Wg is the weight matrix, yt−1 is the input word, ht−1 is the decoder hidden state, and ct is the context vector. After that, we calculate a psychological state vector ctPMR at step t which is taken as the final condition to control model generation.
(8)et,i=VaTtanhWastchar+UahPMR,i,(9)αt,i=expet,i∑i=1cexpet,i,(10)ctPMR=∑i=1cαt,iPMRi,where Wa and Ua are the weight matrices, t is the time step, i is the i-th character, and c is the number of characters.


### 3.3. Knowledge-Enhanced Generation Model

#### 3.3.1. Knowledge Encoding

In order to represent a word more meaningful and a story more coherent, we use knowledge aware representation and attention based on the context to enhance the semantic expression in the encoder. We first calculate a knowledge graph vectorckg which attends to the triple of the words in the knowledge graph, and then a context vector ccon to attend to the context information; both of which are as the input with the sentence together. We get a knowledge graph vector ckg by using graph attention [11]. The words in the sentences have their own knowledge representation by triples. In this way, the words can be enriched by their adjacent nodes and their relations. For a context vector ccon, we use attention [26] method, which reflects the relation between the input sentence and its previous context.
(11)hi=BiLSTMhi−1,X;Ci,cei,where hi is the hidden state of the i-th sentence of the story. cei is the concatenation of the knowledge graph vector ckgi and context vector cconi.
(12)cei=ckgi;cconi,where cconi is the context attention vector of i-th sentence. ckgi is the knowledge graph vector of the i-th sentence and is formulated as follows:
(13)eki=hiWkgxi−1,(14)αki=expeki∑i=1cexpeki,(15)ckgi=∑i=1kαkigxi−1,where gxi−1 is the graph attention vector in [11]. The whole story generation process will always be followed by the knowledge graph vector and context vector, which is the soul that keeps the story coherent.


#### 3.3.2. Incorporating the Knowledge

We concatenate the last time step word embedding vectoreyt−1, PMR context ctPMR, knowledge graph vector ctkg, and attention context ct, which represent incorporating the external knowledge and psychological state into the generation model. The LSTM hidden state is updated as follows:
(16)ht=LSTMeyt−1;ctPMR;ctkg;ct,ht−1.We minimize the negative log-likelihood objective function to generate expected sentences.(17)LNLL=−1N∑i=1N∑t=1TlogPyti∣y<ti,Xi,Ci,PMRi,ki,where N is the story number in the dataset, and T is the time step of the i-th generated sentence in the decoder. Xi represents the i-th sentence in the dataset. Similarly, Ci, PMRi, and Ki represent the i-th context, i-th PMR matrix, and i-th knowledge triples in the dataset, respectively.


## 3.1. Problem Formulation

Formally, the input is a text sequenceX=x1s,⋯,xns that is a begining of the story, which consists of n words. We also take story context C=x1c,⋯,xmc consisting of m words as input to increase the coherence of the story, which represents historical story sentences of the input sentence X. We represent the external knowledge as K=h1,r1,t1,⋯,hl,rl,tl, where hl,rl,tl is the triple consisting of head, relation, and tail. Meanwhile, we quantify a psychological state score of each character for three theories Plutchik, Maslow, and Reiss: Spmr=S1p,S1m,S1r,⋯,Sjp,Sjm,Sjr, where j is the characters’ number in the story. The output target is another text sequence Y=y1,⋯,yk that consists of k words. The task is then formulated as calculating the conditional probability PY∣X,C,PMR,K, where PMR represents the psychological state.


## 3.2. Character Psychological State Controller

The Character Psychological State Controller is used to control which and how much characters’ psychological state can be used to describe the story. For psychological state, because it is composed of multiple psychological states, we quantify the psychological state so that it can be accepted by the model.


### 3.2.1. Psychological State Representation

We quantify a psychological state as a PMR matrix that is used to describe the fine-grained psychological state of characters in the story. As shown in Figure3, we just display Plutchik scores of each character for the third sentence in the story, where the score “0” denotes no current emotion. The higher the score, the richer the current emotion. We normalize these scores and then build a vector for each emotion or motivation. We set the characters number as maximum n for processing different characters in the stories. We concatenate them as multiple characters score matrix, i.e., Plutchik score Sp, Maslow score Sm, and Reiss score Sr. Then, a word vector matrix for the three psychological states is randomly initialized as Vp, Vm, and Vr, respectively. Figure 3 shows the Plutchik score matrix Sp and word vector matrix Vp. For the Plutchik score matrix Sp, we pad the matrix with less than the maximum number of characters. Each row represents a character, and each column represents a score for each emotion. For word vector matrix Vp, each row expresses a representation of an emotion. The word vector matrix will be multiplied by the characters score matrix; then, the product will be mapped into a low dimension space. We obtain the Plutchik matrix, the Maslow matrix, and the Reiss matrix subsequently. The formulation is as follows:
(1)Pi=WpSip×Vip+bp,(2)Mi=WmSim×Vim+bm,(3)Ri=WrSir×Vir+br,where Wp, Wm, and Wr are the weight matrices. bp, bm, and br indicate the biases, and i is the i-th character. The Plutchick, Maslow, and Reiss matrices will be concatenated as characters PMR matrix for the convenience of calculation:
(4)PMRi=WpmrSipmr×Vipmr+bpmr.Figure 3
An example of constructing the PMR matrix. We just attend to the third sentence in blue in the story. There are three characters in this story. The table above shows the Plutchik score for each character in the dataset. The matrix in orange and in green displays the Plutchik score matrixSp and Plutchik word vector matrix Vp, respectively.


### 3.2.2. Controllable Psychological State

We control the multiple characters’ psychological states by first selecting a character who will be described at each decoder time step, and then, the selected character’s psychological state will be controlled using an attention method.At each stept of decoder, we use a feed-forward layer to compute a character gate vector gtchar. The softmax activation is used to calculate a probability distribution of characters in the story; then, a one-hot mechanism picks up a character with maximum probability otchar. We multiply the PMRi with the otchar to obtain the character’s psychological states:
(5)gtchar=softmaxWgyt−1;ht−1;ct,(6)otchar=one‐hotgtchar,(7)stchar=otchar×PMRi,where Wg is the weight matrix, yt−1 is the input word, ht−1 is the decoder hidden state, and ct is the context vector. After that, we calculate a psychological state vector ctPMR at step t which is taken as the final condition to control model generation.
(8)et,i=VaTtanhWastchar+UahPMR,i,(9)αt,i=expet,i∑i=1cexpet,i,(10)ctPMR=∑i=1cαt,iPMRi,where Wa and Ua are the weight matrices, t is the time step, i is the i-th character, and c is the number of characters.


## 3.2.1. Psychological State Representation

We quantify a psychological state as a PMR matrix that is used to describe the fine-grained psychological state of characters in the story. As shown in Figure3, we just display Plutchik scores of each character for the third sentence in the story, where the score “0” denotes no current emotion. The higher the score, the richer the current emotion. We normalize these scores and then build a vector for each emotion or motivation. We set the characters number as maximum n for processing different characters in the stories. We concatenate them as multiple characters score matrix, i.e., Plutchik score Sp, Maslow score Sm, and Reiss score Sr. Then, a word vector matrix for the three psychological states is randomly initialized as Vp, Vm, and Vr, respectively. Figure 3 shows the Plutchik score matrix Sp and word vector matrix Vp. For the Plutchik score matrix Sp, we pad the matrix with less than the maximum number of characters. Each row represents a character, and each column represents a score for each emotion. For word vector matrix Vp, each row expresses a representation of an emotion. The word vector matrix will be multiplied by the characters score matrix; then, the product will be mapped into a low dimension space. We obtain the Plutchik matrix, the Maslow matrix, and the Reiss matrix subsequently. The formulation is as follows:
(1)Pi=WpSip×Vip+bp,(2)Mi=WmSim×Vim+bm,(3)Ri=WrSir×Vir+br,where Wp, Wm, and Wr are the weight matrices. bp, bm, and br indicate the biases, and i is the i-th character. The Plutchick, Maslow, and Reiss matrices will be concatenated as characters PMR matrix for the convenience of calculation:
(4)PMRi=WpmrSipmr×Vipmr+bpmr.Figure 3
An example of constructing the PMR matrix. We just attend to the third sentence in blue in the story. There are three characters in this story. The table above shows the Plutchik score for each character in the dataset. The matrix in orange and in green displays the Plutchik score matrixSp and Plutchik word vector matrix Vp, respectively.


## 3.2.2. Controllable Psychological State

We control the multiple characters’ psychological states by first selecting a character who will be described at each decoder time step, and then, the selected character’s psychological state will be controlled using an attention method.At each stept of decoder, we use a feed-forward layer to compute a character gate vector gtchar. The softmax activation is used to calculate a probability distribution of characters in the story; then, a one-hot mechanism picks up a character with maximum probability otchar. We multiply the PMRi with the otchar to obtain the character’s psychological states:
(5)gtchar=softmaxWgyt−1;ht−1;ct,(6)otchar=one‐hotgtchar,(7)stchar=otchar×PMRi,where Wg is the weight matrix, yt−1 is the input word, ht−1 is the decoder hidden state, and ct is the context vector. After that, we calculate a psychological state vector ctPMR at step t which is taken as the final condition to control model generation.
(8)et,i=VaTtanhWastchar+UahPMR,i,(9)αt,i=expet,i∑i=1cexpet,i,(10)ctPMR=∑i=1cαt,iPMRi,where Wa and Ua are the weight matrices, t is the time step, i is the i-th character, and c is the number of characters.


## 3.3. Knowledge-Enhanced Generation Model

### 3.3.1. Knowledge Encoding

In order to represent a word more meaningful and a story more coherent, we use knowledge aware representation and attention based on the context to enhance the semantic expression in the encoder. We first calculate a knowledge graph vectorckg which attends to the triple of the words in the knowledge graph, and then a context vector ccon to attend to the context information; both of which are as the input with the sentence together. We get a knowledge graph vector ckg by using graph attention [11]. The words in the sentences have their own knowledge representation by triples. In this way, the words can be enriched by their adjacent nodes and their relations. For a context vector ccon, we use attention [26] method, which reflects the relation between the input sentence and its previous context.
(11)hi=BiLSTMhi−1,X;Ci,cei,where hi is the hidden state of the i-th sentence of the story. cei is the concatenation of the knowledge graph vector ckgi and context vector cconi.
(12)cei=ckgi;cconi,where cconi is the context attention vector of i-th sentence. ckgi is the knowledge graph vector of the i-th sentence and is formulated as follows:
(13)eki=hiWkgxi−1,(14)αki=expeki∑i=1cexpeki,(15)ckgi=∑i=1kαkigxi−1,where gxi−1 is the graph attention vector in [11]. The whole story generation process will always be followed by the knowledge graph vector and context vector, which is the soul that keeps the story coherent.


### 3.3.2. Incorporating the Knowledge

We concatenate the last time step word embedding vectoreyt−1, PMR context ctPMR, knowledge graph vector ctkg, and attention context ct, which represent incorporating the external knowledge and psychological state into the generation model. The LSTM hidden state is updated as follows:
(16)ht=LSTMeyt−1;ctPMR;ctkg;ct,ht−1.We minimize the negative log-likelihood objective function to generate expected sentences.(17)LNLL=−1N∑i=1N∑t=1TlogPyti∣y<ti,Xi,Ci,PMRi,ki,where N is the story number in the dataset, and T is the time step of the i-th generated sentence in the decoder. Xi represents the i-th sentence in the dataset. Similarly, Ci, PMRi, and Ki represent the i-th context, i-th PMR matrix, and i-th knowledge triples in the dataset, respectively.


## 3.3.1. Knowledge Encoding

In order to represent a word more meaningful and a story more coherent, we use knowledge aware representation and attention based on the context to enhance the semantic expression in the encoder. We first calculate a knowledge graph vectorckg which attends to the triple of the words in the knowledge graph, and then a context vector ccon to attend to the context information; both of which are as the input with the sentence together. We get a knowledge graph vector ckg by using graph attention [11]. The words in the sentences have their own knowledge representation by triples. In this way, the words can be enriched by their adjacent nodes and their relations. For a context vector ccon, we use attention [26] method, which reflects the relation between the input sentence and its previous context.
(11)hi=BiLSTMhi−1,X;Ci,cei,where hi is the hidden state of the i-th sentence of the story. cei is the concatenation of the knowledge graph vector ckgi and context vector cconi.
(12)cei=ckgi;cconi,where cconi is the context attention vector of i-th sentence. ckgi is the knowledge graph vector of the i-th sentence and is formulated as follows:
(13)eki=hiWkgxi−1,(14)αki=expeki∑i=1cexpeki,(15)ckgi=∑i=1kαkigxi−1,where gxi−1 is the graph attention vector in [11]. The whole story generation process will always be followed by the knowledge graph vector and context vector, which is the soul that keeps the story coherent.


## 3.3.2. Incorporating the Knowledge

We concatenate the last time step word embedding vectoreyt−1, PMR context ctPMR, knowledge graph vector ctkg, and attention context ct, which represent incorporating the external knowledge and psychological state into the generation model. The LSTM hidden state is updated as follows:
(16)ht=LSTMeyt−1;ctPMR;ctkg;ct,ht−1.We minimize the negative log-likelihood objective function to generate expected sentences.(17)LNLL=−1N∑i=1N∑t=1TlogPyti∣y<ti,Xi,Ci,PMRi,ki,where N is the story number in the dataset, and T is the time step of the i-th generated sentence in the decoder. Xi represents the i-th sentence in the dataset. Similarly, Ci, PMRi, and Ki represent the i-th context, i-th PMR matrix, and i-th knowledge triples in the dataset, respectively.


## 4. Experiments

### 4.1. Dataset

The dataset in [21] is chosen as our story corpus, consisting of 4 k five-sentence stories. The corpus contains stories where each sentence is not only annotated but also with characters and three psychological theories. Figure 4 displays the statistic of the psychological states. Plutchik’s emotion appears more frequently than Maslow’s and Reiss’s motivation. Particularly, “joy” and “participation” are most in the Plutchik states. The Reiss categories are subcategories of the Maslow categories. We use different methods to process the dataset for Plutchik, Maslow, and Reiss. Three workers who are employed by the original author annotate the original data. Intuitively, the workers will have different viewpoints, so we sum up the Plutchik scores and normalize them. Maslow and Reiss have no repeated words; thus, we use a one-hot vector to represent them. We split the data as 80% for training and 20% for testing. In the test phase, we input the story’s first sentence and the normalized psychological states scores. Table 2 statistics the character number in each story sentence. They are most in the range 1-3, and the largest character number is 6. Thus, we set the character number as 3.Figure 4
The statistic of psychological states. “Anticipation” is the most frequent state in Plutchick’s wheel of emotion, while “belonging” is the least frequent state in the Reiss classification.Table 2
The statistic of character number.
Character numberSentence number1110082654731254416453661


### 4.2. Baselines

We compare our model with representative baselines to investigate the effectiveness of the K-GuCCI model. The baselines are as follows:Seq2Seq model introduced by Google in 2014 and has encoder, decoder, and intermediate step as its main components. The model can map input text with fixed length to output text with fixed length. It is widely used in text generation tasks. Our model is improved based on Seq2Seq. Therefore, the Seq2Seq baseline can be used to compare to prove our model’s effect on emotional controllability and fluency.Inc-S2S is an incremental Seq2Seq model mentioned in [3]. Different from the implementation in [3], we incorporate the psychological states into the model. The story sentences are generated according to the beginning of the story sentence and context. Compared with the Inc-S2S model, the effectiveness of the Character Psychological State Controller can be proved.Transformer [27] is a novel architecture that aims at solving natural language processing tasks while handling long-range dependencies with ease. Since the Transformer model facilitates more parallelization during training, it has led to the development of pretrained models such as BERT [28], GPT-2 [29], and Transformer-xl [30], which have been trained with huge general language datasets.GPT-2 [29] shows an impressive ability to write coherent and passionate essays. Its architecture is composed of the decoder-only transformer and it can be trained on a massive dataset. There are many works in natural language generation tasks that use GPT-2-based model.SoCP [10] proposes a novel model called SoCP, which can generate a story according to the characters’ psychological states. The model is most relative to us. Different from that, our model introduces a knowledge graph to enhance semantic information and promote the coherence of the story.


### 4.3. Experimental Settings

Based on the above, we fix the character number to three. If the character number is smaller than three, use “none” as a character. The pretrained glove 300 dimension vector is used as our word embedding vector. We map the PMR matrix from a high dimension to a 256 low dimension. We implement the encoder as a two-layer bidirectional LSTM and the decoder as a one-layer LSTM with a 256 hidden size. The batch size is 8, and 0.2 is the dropout [31]. The learning rate of Adam optimizer [32] is initialed as 0.0003.


### 4.4. Evaluation Metrics

BLEU [33] is a metric to quantify the effectiveness of generated text according to compare a candidate sentence of the text to one or more reference label sentences. Although designed for translation, it is commonly utilized for a suite of natural language processing tasks.ROUGE, stands for Recall Oriented Understudy for Gisting Evaluation, is a set of metrics used for evaluating the automatic text summarization and machine translations. The metrics basically compare the similarity between generated sentences and reference sentences.METEOR is based on the harmonic mean of unigram accuracy and recall, weighted higher than accuracy with recall. In the more common BLEU metric, the metric will correct some of the issues and also produce a strong correlation with human judgement at the level of the sentence or section.InAGPS (Accuracy of Generated Psychological State), we pretrain a classifier to evaluate the accuracy of the generated psychological state. There are many approaches to train a classifier [34–36]. We utilize bidirectional LSTM to pretrain a classifier to classify the generated sentence like sentiment classification. This demonstrates our model’s capacity to convey emotions. The name of the character Char and the sentence X as input are concatenated. In this fashion, several training pairs with different outputs in similar sentences can be obtained when different characters in a sentence have various psychological states. The compact vector hclf can be accessed by BiLSTM, and then, we utilize two feed-forward layers to compact it into the output size.
(18)hclf=BiLSTMChar;X,(19)p=WpReluWohclf+bo+bp.


### 4.5. Result Analysis

We have the Seq2Seq framework, the Inc-S2S, and Transformer as the baseline model. We use automatic assessment metrics, including the proposed metric AGPS, to compare our model with baseline models’ effectiveness. The experiments can prove our components and demonstrate the consistency in which the generated sentence psychological states correspond with our previous collection. All matrix’ scores in our model are the highest, as seen in Table3, which shows the effect of our built modules, and the generated sentences are coherent.Table 3
Automatic evaluations of the proposed model and the baseline models. The context-merge and context-independent represent different methods of encoder mentioned in [10]. The former is to encode the context and sentence together, while the latter encodes them separately and then concatenates them.
ModelBLEUROUGEMETEORAGPSB-1B-2B-3B-4R-1R-2R-lSeq2Seq0.2020.0490.0160.0070.1220.0140.1170.0620.654Transformer0.2070.0530.0200.0080.1390.0120.1280.0690.747Inc-S2S0.2240.0530.0170.0060.1510.0130.1410.0670.825SoCP+context-merger0.2160.0560.0210.0100.1440.0160.1360.0670.886SoCP+context-independent0.2320.0620.0250.0110.1610.0180.1510.0720.879(Ours)K-GuCCI0.2420.0700.0290.0140.1690.0220.1600.0770.914We see that Seq2Seq has better results for BLEU, ROUGE, and METEOR than the Transformer framework. The reason may be that the Seq2Seq model is more appropriate for short texts than Transformer. In addition, the outcomes of our method are better than the SoCP with context-merge method and context-independent method. The effectiveness of external knowledge that can enrich the generated stories is also reflected in this table. Our proposed model, of all the ones, has the best efficiency. The training speed of the Transformer, however, is much higher than that of Seq2Seq. It reflects the benefit of the Transformer in training speed because of the parallelism of operation.We design AGPS to assess whether the emotion of the generated sentences is consistent with the settings. We intuitively assume that the score without input emotion will be lower. The performance of Inc-s2s is between our model and other models, which shows that our model performs efficiently for our built components.The result of the K-GuCCI model is better than that of the SoCP model, which shows that the story can be enriched by introducing knowledge.


### 4.6. Model Effect Analysis

#### 4.6.1. The Effect of the Character Psychological State Controller

We display the attention weight distribution to demonstrate the relation between the generated sentences and psychological states. As seen in Figure5, the model provides interpretability dependent on the character’s psychological state controller. The brighter the square corresponding to the two words while generating the next word is, the stronger the relationship between them will be. Visualization of the focus maps offers a proof of the model’s ability to recognize which psychological state corresponds to the character. A word may have many different color squares, suggesting that our component can read several characters’ psychological states automatically and can select the psychological states for the character automatically. The black square suggests that no responsible psychological state is reached because the feeling is not actually conveyed by all words, such as “a” and “the”. The model correctly chooses the elements from the psychological states in the examples displayed. The first example focuses on the emotions of Plutchik, such as “fear” and “anger,” while the second example discusses Maslow and Reiss’s elements, such as “spiritual growth” and “indep.” The term “hospital” is correlated with the Plutchik in the third attention diagram, such as “fear,” “surprise,” and “sadness,” implying that “hospital” is typically associated with a character’s negative emotion. In the fourth attention diagram, the word “however” predicts a vital turning point and negative outcomes that the character will be failed in the exam, which is also compatible with the “depression” and “anger” emotions.Figure 5
Visualization of our Character Psychological State Controller. The row in the figure is the fine-grained emotion and motivation of the three psychological states, and the column represents the generated sentence. In the graph, the brighter the grid, the more attention there is between rows and columns.
(a)
Attention map 1(b)
Attention map 2(c)
Attention map 3(d)
Attention map 4


#### 4.6.2. The Effect of the External Knowledge

As seen in Table4, the evaluation matrix shows that the performance of our model is better than other models. In addition, K-GuCCI demonstrates the effect of external knowledge in Table 4. For example, “necklace” is linked to “like it,” and “losing his mind” is linked to “go to the hospital,” which illustrates that the generated stories are coherent and reasonable. In the meantime, the conditions we set can control the stories while the coherence of the story is assured. With our setting, as we assigned the Plutchik emotional lines, the emotions of the stories will shift.Table 4
Examples generated by the proposed model and the baseline models.
Jane bought a new necklace.The man next door seemed to be losing his mind.InputCharacters: Jane, friendsCharacters: manPlutchik: joy-joy-joy-joy-joy, none-none-joy-none-nonePlutchik: fear-disgust-surprise-surprise-joyMaslow: esteem, loveMaslow: spiritual growthReiss: approvalReiss: statusSeq2SeqShe was running it.He was very happy to have a new job.She was amazed by it.He was not sure where he was going.She tried it.He was not sure where he was going.She was thankful of Jane with it.He was not sure where to go.Inc-S2SShe was not sure if she wanted to go to the store.He asked his credit hour he did not know how.She was very happy.He asked his parents would help him some directions.She was very happy.He tied the games and tied miles.She was so happy that she had a good time.He was sad that he realized his card.TransformerShe decided to do something about it.He yelled at him.She did not have any money.He had to go to the hospital.She decided to save money.He asked his girlfriend.She decided to save up.She said yes right away.GPT-2“I’m not sure if I’m going to be able to wear it anymore,” she said.“I’m sorry, but I’m not going to be able to go to the hospital,” he said.“I’m not sure if I’m going to be able to wear it anymore.”“I’m not going to be able to go to the hospital.”She said she’s been looking for a way to get rid of the necklace.The man next door was also in shock.“I’m not sure if I’m going to be able to wear it anymore,” she said.“I’m not going to be able to go to the hospital,” he said.SoCPShe was excited to get a job.He was very angry and did not want to do.Her friend was on the same.He was a detective man about the problem.She was very happy.The man was not the wrong man.She was happy to the best game.He was able to beat the ball and he was shot.K-GuCCIShe was a great man.He was very angry and did not want to go to the hospital.Her friend was very excited.He was very surprised; he was not very tall as he got to the man.She really liked it.He was surprised by the organizers.She was very excited.He was very excited to be nice.


### 4.7. Case Study

#### 4.7.1. Comparison with Baseline Models

The examples of stories generated by our model and the baseline models are shown in Table4. A coherent story can be constructed by the psychological state condition we have given.We see that it generates typically repetitive sentences by the Seq2Seq model, and it cannot accept all the characters. In Table4, example 1 produced by the baseline model describes only one character “Jane,” but can generate “friends” by the K-GuCCI. In example 2, we see that with our defined psychological state condition, the baseline model cannot vary the story and even have incorrect feelings, but our K-GuCCI model can match it correctly. The GPT-2 model is capable of generating rational phrases but has several repetitions.Overall, by manipulating the feelings of the characters, our proposed model will generate good stories. There are also some stories that are not coherent, so it is still a challenge for us.


#### 4.7.2. Controllability

The examples in Table5 show the controllability of generated stories under different psychological state conditions. The first example in Table 5 compares the generated stories under various condition scores using an identical Plutchik element. In specific, we set the Plutchik “joy” with different scores in the first example. Some obvious terms such as “great,” “excited,” or “really liked” are produced when the score sets 1. As the “joy” score gets lower and lower, the terms produced get more and more negative. When the score is set to 0, some negative terms, such as “nervous” or “not good” are produced. The second example shows the produced stories with various indicators from Plutchik. We assign various Plutchik indicators to “surprise,” “fear,” and “anger.” It produces several words, such as “was surprised” or “shocked” when Plutchik is “surprise.” When Plutchik is “fear,” the words “was afraid of” or “scared” are formed. The term “angry” can be formed when Plutchik is “anger.” In the third case, for the multiple Plutchik metrics, separate scores are assigned. In the third case, in the produced stories, several emotions are portrayed.Table 5
Examples of controllable generated stories.
Input sentenceJane bought a new necklace.CharacterJaneMaslowEsteem, loveReissApprovalGenerated stories with the same Plutchik indicator “joy” under different scoresJoy = 1Joy = 0.5Joy = 0Jane bought a new necklace.Jane bought a new necklace.Jane bought a new necklace.She was a great man.She was a new person; it was a bit huge.She was a person and it was a bit huge.Her friend was very excited.She was excited.The man was not good and she was very nervous.She really liked it.She always had been in the car, and it was fun.She was really wanted it; the baby was gone.She was very excited.She was really allowed to go to the beach.She was pulled in the car; It was gone.Generated stories with different Plutchik indicatorsSurprise = 1Fear = 1Anger = 1Jane bought a new necklace.Jane bought a new necklace.Jane bought a new necklace.She was surprised to see what she had been.She was nervous.She was nervous.The man was upset.She was nervous.She was angry about it.The man was shocked.She was afraid and was going to be scared.She tried to be a person; a man came into the car.The man was not friendly.She was going to the car that was very crowded.The man was pulled over the police’s car.Generated stories with multiple Plutchik indicatorsTrust = 1, joy = 0.5Sadness = 0.4, anticipation = 0.8Fear = 1, disgust = 0.5Jane bought a new necklace.Jane bought a new necklace.Jane bought a new necklace.The man was a nice man.She was very tired and she was not able to go.She was nervous.The man was very good and they were very good.She was nervous.She was afraid.The man was always had been in the car.She was nervous and her friends were not allowed to go.She was afraid and her friends were going to be scared.The man was very close in the car.She was nervous and decided to go to the party.She was nervous and went to the car; she was very scaredThe above examples demonstrate the controllability of our model. On the other hand, in the examples mentioned above, several incoherent stories tell us that although the model performs well in emotion control, it still needs to be improved in coherence.


## 4.1. Dataset

The dataset in [21] is chosen as our story corpus, consisting of 4 k five-sentence stories. The corpus contains stories where each sentence is not only annotated but also with characters and three psychological theories. Figure 4 displays the statistic of the psychological states. Plutchik’s emotion appears more frequently than Maslow’s and Reiss’s motivation. Particularly, “joy” and “participation” are most in the Plutchik states. The Reiss categories are subcategories of the Maslow categories. We use different methods to process the dataset for Plutchik, Maslow, and Reiss. Three workers who are employed by the original author annotate the original data. Intuitively, the workers will have different viewpoints, so we sum up the Plutchik scores and normalize them. Maslow and Reiss have no repeated words; thus, we use a one-hot vector to represent them. We split the data as 80% for training and 20% for testing. In the test phase, we input the story’s first sentence and the normalized psychological states scores. Table 2 statistics the character number in each story sentence. They are most in the range 1-3, and the largest character number is 6. Thus, we set the character number as 3.Figure 4
The statistic of psychological states. “Anticipation” is the most frequent state in Plutchick’s wheel of emotion, while “belonging” is the least frequent state in the Reiss classification.Table 2
The statistic of character number.
Character numberSentence number1110082654731254416453661


## 4.2. Baselines

We compare our model with representative baselines to investigate the effectiveness of the K-GuCCI model. The baselines are as follows:Seq2Seq model introduced by Google in 2014 and has encoder, decoder, and intermediate step as its main components. The model can map input text with fixed length to output text with fixed length. It is widely used in text generation tasks. Our model is improved based on Seq2Seq. Therefore, the Seq2Seq baseline can be used to compare to prove our model’s effect on emotional controllability and fluency.Inc-S2S is an incremental Seq2Seq model mentioned in [3]. Different from the implementation in [3], we incorporate the psychological states into the model. The story sentences are generated according to the beginning of the story sentence and context. Compared with the Inc-S2S model, the effectiveness of the Character Psychological State Controller can be proved.Transformer [27] is a novel architecture that aims at solving natural language processing tasks while handling long-range dependencies with ease. Since the Transformer model facilitates more parallelization during training, it has led to the development of pretrained models such as BERT [28], GPT-2 [29], and Transformer-xl [30], which have been trained with huge general language datasets.GPT-2 [29] shows an impressive ability to write coherent and passionate essays. Its architecture is composed of the decoder-only transformer and it can be trained on a massive dataset. There are many works in natural language generation tasks that use GPT-2-based model.SoCP [10] proposes a novel model called SoCP, which can generate a story according to the characters’ psychological states. The model is most relative to us. Different from that, our model introduces a knowledge graph to enhance semantic information and promote the coherence of the story.


## 4.3. Experimental Settings

Based on the above, we fix the character number to three. If the character number is smaller than three, use “none” as a character. The pretrained glove 300 dimension vector is used as our word embedding vector. We map the PMR matrix from a high dimension to a 256 low dimension. We implement the encoder as a two-layer bidirectional LSTM and the decoder as a one-layer LSTM with a 256 hidden size. The batch size is 8, and 0.2 is the dropout [31]. The learning rate of Adam optimizer [32] is initialed as 0.0003.


## 4.4. Evaluation Metrics

BLEU [33] is a metric to quantify the effectiveness of generated text according to compare a candidate sentence of the text to one or more reference label sentences. Although designed for translation, it is commonly utilized for a suite of natural language processing tasks.ROUGE, stands for Recall Oriented Understudy for Gisting Evaluation, is a set of metrics used for evaluating the automatic text summarization and machine translations. The metrics basically compare the similarity between generated sentences and reference sentences.METEOR is based on the harmonic mean of unigram accuracy and recall, weighted higher than accuracy with recall. In the more common BLEU metric, the metric will correct some of the issues and also produce a strong correlation with human judgement at the level of the sentence or section.InAGPS (Accuracy of Generated Psychological State), we pretrain a classifier to evaluate the accuracy of the generated psychological state. There are many approaches to train a classifier [34–36]. We utilize bidirectional LSTM to pretrain a classifier to classify the generated sentence like sentiment classification. This demonstrates our model’s capacity to convey emotions. The name of the character Char and the sentence X as input are concatenated. In this fashion, several training pairs with different outputs in similar sentences can be obtained when different characters in a sentence have various psychological states. The compact vector hclf can be accessed by BiLSTM, and then, we utilize two feed-forward layers to compact it into the output size.
(18)hclf=BiLSTMChar;X,(19)p=WpReluWohclf+bo+bp.


## 4.5. Result Analysis

We have the Seq2Seq framework, the Inc-S2S, and Transformer as the baseline model. We use automatic assessment metrics, including the proposed metric AGPS, to compare our model with baseline models’ effectiveness. The experiments can prove our components and demonstrate the consistency in which the generated sentence psychological states correspond with our previous collection. All matrix’ scores in our model are the highest, as seen in Table3, which shows the effect of our built modules, and the generated sentences are coherent.Table 3
Automatic evaluations of the proposed model and the baseline models. The context-merge and context-independent represent different methods of encoder mentioned in [10]. The former is to encode the context and sentence together, while the latter encodes them separately and then concatenates them.
ModelBLEUROUGEMETEORAGPSB-1B-2B-3B-4R-1R-2R-lSeq2Seq0.2020.0490.0160.0070.1220.0140.1170.0620.654Transformer0.2070.0530.0200.0080.1390.0120.1280.0690.747Inc-S2S0.2240.0530.0170.0060.1510.0130.1410.0670.825SoCP+context-merger0.2160.0560.0210.0100.1440.0160.1360.0670.886SoCP+context-independent0.2320.0620.0250.0110.1610.0180.1510.0720.879(Ours)K-GuCCI0.2420.0700.0290.0140.1690.0220.1600.0770.914We see that Seq2Seq has better results for BLEU, ROUGE, and METEOR than the Transformer framework. The reason may be that the Seq2Seq model is more appropriate for short texts than Transformer. In addition, the outcomes of our method are better than the SoCP with context-merge method and context-independent method. The effectiveness of external knowledge that can enrich the generated stories is also reflected in this table. Our proposed model, of all the ones, has the best efficiency. The training speed of the Transformer, however, is much higher than that of Seq2Seq. It reflects the benefit of the Transformer in training speed because of the parallelism of operation.We design AGPS to assess whether the emotion of the generated sentences is consistent with the settings. We intuitively assume that the score without input emotion will be lower. The performance of Inc-s2s is between our model and other models, which shows that our model performs efficiently for our built components.The result of the K-GuCCI model is better than that of the SoCP model, which shows that the story can be enriched by introducing knowledge.


## 4.6. Model Effect Analysis

### 4.6.1. The Effect of the Character Psychological State Controller

We display the attention weight distribution to demonstrate the relation between the generated sentences and psychological states. As seen in Figure5, the model provides interpretability dependent on the character’s psychological state controller. The brighter the square corresponding to the two words while generating the next word is, the stronger the relationship between them will be. Visualization of the focus maps offers a proof of the model’s ability to recognize which psychological state corresponds to the character. A word may have many different color squares, suggesting that our component can read several characters’ psychological states automatically and can select the psychological states for the character automatically. The black square suggests that no responsible psychological state is reached because the feeling is not actually conveyed by all words, such as “a” and “the”. The model correctly chooses the elements from the psychological states in the examples displayed. The first example focuses on the emotions of Plutchik, such as “fear” and “anger,” while the second example discusses Maslow and Reiss’s elements, such as “spiritual growth” and “indep.” The term “hospital” is correlated with the Plutchik in the third attention diagram, such as “fear,” “surprise,” and “sadness,” implying that “hospital” is typically associated with a character’s negative emotion. In the fourth attention diagram, the word “however” predicts a vital turning point and negative outcomes that the character will be failed in the exam, which is also compatible with the “depression” and “anger” emotions.Figure 5
Visualization of our Character Psychological State Controller. The row in the figure is the fine-grained emotion and motivation of the three psychological states, and the column represents the generated sentence. In the graph, the brighter the grid, the more attention there is between rows and columns.
(a)
Attention map 1(b)
Attention map 2(c)
Attention map 3(d)
Attention map 4


### 4.6.2. The Effect of the External Knowledge

As seen in Table4, the evaluation matrix shows that the performance of our model is better than other models. In addition, K-GuCCI demonstrates the effect of external knowledge in Table 4. For example, “necklace” is linked to “like it,” and “losing his mind” is linked to “go to the hospital,” which illustrates that the generated stories are coherent and reasonable. In the meantime, the conditions we set can control the stories while the coherence of the story is assured. With our setting, as we assigned the Plutchik emotional lines, the emotions of the stories will shift.Table 4
Examples generated by the proposed model and the baseline models.
Jane bought a new necklace.The man next door seemed to be losing his mind.InputCharacters: Jane, friendsCharacters: manPlutchik: joy-joy-joy-joy-joy, none-none-joy-none-nonePlutchik: fear-disgust-surprise-surprise-joyMaslow: esteem, loveMaslow: spiritual growthReiss: approvalReiss: statusSeq2SeqShe was running it.He was very happy to have a new job.She was amazed by it.He was not sure where he was going.She tried it.He was not sure where he was going.She was thankful of Jane with it.He was not sure where to go.Inc-S2SShe was not sure if she wanted to go to the store.He asked his credit hour he did not know how.She was very happy.He asked his parents would help him some directions.She was very happy.He tied the games and tied miles.She was so happy that she had a good time.He was sad that he realized his card.TransformerShe decided to do something about it.He yelled at him.She did not have any money.He had to go to the hospital.She decided to save money.He asked his girlfriend.She decided to save up.She said yes right away.GPT-2“I’m not sure if I’m going to be able to wear it anymore,” she said.“I’m sorry, but I’m not going to be able to go to the hospital,” he said.“I’m not sure if I’m going to be able to wear it anymore.”“I’m not going to be able to go to the hospital.”She said she’s been looking for a way to get rid of the necklace.The man next door was also in shock.“I’m not sure if I’m going to be able to wear it anymore,” she said.“I’m not going to be able to go to the hospital,” he said.SoCPShe was excited to get a job.He was very angry and did not want to do.Her friend was on the same.He was a detective man about the problem.She was very happy.The man was not the wrong man.She was happy to the best game.He was able to beat the ball and he was shot.K-GuCCIShe was a great man.He was very angry and did not want to go to the hospital.Her friend was very excited.He was very surprised; he was not very tall as he got to the man.She really liked it.He was surprised by the organizers.She was very excited.He was very excited to be nice.


## 4.6.1. The Effect of the Character Psychological State Controller

We display the attention weight distribution to demonstrate the relation between the generated sentences and psychological states. As seen in Figure5, the model provides interpretability dependent on the character’s psychological state controller. The brighter the square corresponding to the two words while generating the next word is, the stronger the relationship between them will be. Visualization of the focus maps offers a proof of the model’s ability to recognize which psychological state corresponds to the character. A word may have many different color squares, suggesting that our component can read several characters’ psychological states automatically and can select the psychological states for the character automatically. The black square suggests that no responsible psychological state is reached because the feeling is not actually conveyed by all words, such as “a” and “the”. The model correctly chooses the elements from the psychological states in the examples displayed. The first example focuses on the emotions of Plutchik, such as “fear” and “anger,” while the second example discusses Maslow and Reiss’s elements, such as “spiritual growth” and “indep.” The term “hospital” is correlated with the Plutchik in the third attention diagram, such as “fear,” “surprise,” and “sadness,” implying that “hospital” is typically associated with a character’s negative emotion. In the fourth attention diagram, the word “however” predicts a vital turning point and negative outcomes that the character will be failed in the exam, which is also compatible with the “depression” and “anger” emotions.Figure 5
Visualization of our Character Psychological State Controller. The row in the figure is the fine-grained emotion and motivation of the three psychological states, and the column represents the generated sentence. In the graph, the brighter the grid, the more attention there is between rows and columns.
(a)
Attention map 1(b)
Attention map 2(c)
Attention map 3(d)
Attention map 4


## 4.6.2. The Effect of the External Knowledge

As seen in Table4, the evaluation matrix shows that the performance of our model is better than other models. In addition, K-GuCCI demonstrates the effect of external knowledge in Table 4. For example, “necklace” is linked to “like it,” and “losing his mind” is linked to “go to the hospital,” which illustrates that the generated stories are coherent and reasonable. In the meantime, the conditions we set can control the stories while the coherence of the story is assured. With our setting, as we assigned the Plutchik emotional lines, the emotions of the stories will shift.Table 4
Examples generated by the proposed model and the baseline models.
Jane bought a new necklace.The man next door seemed to be losing his mind.InputCharacters: Jane, friendsCharacters: manPlutchik: joy-joy-joy-joy-joy, none-none-joy-none-nonePlutchik: fear-disgust-surprise-surprise-joyMaslow: esteem, loveMaslow: spiritual growthReiss: approvalReiss: statusSeq2SeqShe was running it.He was very happy to have a new job.She was amazed by it.He was not sure where he was going.She tried it.He was not sure where he was going.She was thankful of Jane with it.He was not sure where to go.Inc-S2SShe was not sure if she wanted to go to the store.He asked his credit hour he did not know how.She was very happy.He asked his parents would help him some directions.She was very happy.He tied the games and tied miles.She was so happy that she had a good time.He was sad that he realized his card.TransformerShe decided to do something about it.He yelled at him.She did not have any money.He had to go to the hospital.She decided to save money.He asked his girlfriend.She decided to save up.She said yes right away.GPT-2“I’m not sure if I’m going to be able to wear it anymore,” she said.“I’m sorry, but I’m not going to be able to go to the hospital,” he said.“I’m not sure if I’m going to be able to wear it anymore.”“I’m not going to be able to go to the hospital.”She said she’s been looking for a way to get rid of the necklace.The man next door was also in shock.“I’m not sure if I’m going to be able to wear it anymore,” she said.“I’m not going to be able to go to the hospital,” he said.SoCPShe was excited to get a job.He was very angry and did not want to do.Her friend was on the same.He was a detective man about the problem.She was very happy.The man was not the wrong man.She was happy to the best game.He was able to beat the ball and he was shot.K-GuCCIShe was a great man.He was very angry and did not want to go to the hospital.Her friend was very excited.He was very surprised; he was not very tall as he got to the man.She really liked it.He was surprised by the organizers.She was very excited.He was very excited to be nice.


## 4.7. Case Study

### 4.7.1. Comparison with Baseline Models

The examples of stories generated by our model and the baseline models are shown in Table4. A coherent story can be constructed by the psychological state condition we have given.We see that it generates typically repetitive sentences by the Seq2Seq model, and it cannot accept all the characters. In Table4, example 1 produced by the baseline model describes only one character “Jane,” but can generate “friends” by the K-GuCCI. In example 2, we see that with our defined psychological state condition, the baseline model cannot vary the story and even have incorrect feelings, but our K-GuCCI model can match it correctly. The GPT-2 model is capable of generating rational phrases but has several repetitions.Overall, by manipulating the feelings of the characters, our proposed model will generate good stories. There are also some stories that are not coherent, so it is still a challenge for us.


### 4.7.2. Controllability

The examples in Table5 show the controllability of generated stories under different psychological state conditions. The first example in Table 5 compares the generated stories under various condition scores using an identical Plutchik element. In specific, we set the Plutchik “joy” with different scores in the first example. Some obvious terms such as “great,” “excited,” or “really liked” are produced when the score sets 1. As the “joy” score gets lower and lower, the terms produced get more and more negative. When the score is set to 0, some negative terms, such as “nervous” or “not good” are produced. The second example shows the produced stories with various indicators from Plutchik. We assign various Plutchik indicators to “surprise,” “fear,” and “anger.” It produces several words, such as “was surprised” or “shocked” when Plutchik is “surprise.” When Plutchik is “fear,” the words “was afraid of” or “scared” are formed. The term “angry” can be formed when Plutchik is “anger.” In the third case, for the multiple Plutchik metrics, separate scores are assigned. In the third case, in the produced stories, several emotions are portrayed.Table 5
Examples of controllable generated stories.
Input sentenceJane bought a new necklace.CharacterJaneMaslowEsteem, loveReissApprovalGenerated stories with the same Plutchik indicator “joy” under different scoresJoy = 1Joy = 0.5Joy = 0Jane bought a new necklace.Jane bought a new necklace.Jane bought a new necklace.She was a great man.She was a new person; it was a bit huge.She was a person and it was a bit huge.Her friend was very excited.She was excited.The man was not good and she was very nervous.She really liked it.She always had been in the car, and it was fun.She was really wanted it; the baby was gone.She was very excited.She was really allowed to go to the beach.She was pulled in the car; It was gone.Generated stories with different Plutchik indicatorsSurprise = 1Fear = 1Anger = 1Jane bought a new necklace.Jane bought a new necklace.Jane bought a new necklace.She was surprised to see what she had been.She was nervous.She was nervous.The man was upset.She was nervous.She was angry about it.The man was shocked.She was afraid and was going to be scared.She tried to be a person; a man came into the car.The man was not friendly.She was going to the car that was very crowded.The man was pulled over the police’s car.Generated stories with multiple Plutchik indicatorsTrust = 1, joy = 0.5Sadness = 0.4, anticipation = 0.8Fear = 1, disgust = 0.5Jane bought a new necklace.Jane bought a new necklace.Jane bought a new necklace.The man was a nice man.She was very tired and she was not able to go.She was nervous.The man was very good and they were very good.She was nervous.She was afraid.The man was always had been in the car.She was nervous and her friends were not allowed to go.She was afraid and her friends were going to be scared.The man was very close in the car.She was nervous and decided to go to the party.She was nervous and went to the car; she was very scaredThe above examples demonstrate the controllability of our model. On the other hand, in the examples mentioned above, several incoherent stories tell us that although the model performs well in emotion control, it still needs to be improved in coherence.


## 4.7.1. Comparison with Baseline Models

The examples of stories generated by our model and the baseline models are shown in Table4. A coherent story can be constructed by the psychological state condition we have given.We see that it generates typically repetitive sentences by the Seq2Seq model, and it cannot accept all the characters. In Table4, example 1 produced by the baseline model describes only one character “Jane,” but can generate “friends” by the K-GuCCI. In example 2, we see that with our defined psychological state condition, the baseline model cannot vary the story and even have incorrect feelings, but our K-GuCCI model can match it correctly. The GPT-2 model is capable of generating rational phrases but has several repetitions.Overall, by manipulating the feelings of the characters, our proposed model will generate good stories. There are also some stories that are not coherent, so it is still a challenge for us.


## 4.7.2. Controllability

The examples in Table5 show the controllability of generated stories under different psychological state conditions. The first example in Table 5 compares the generated stories under various condition scores using an identical Plutchik element. In specific, we set the Plutchik “joy” with different scores in the first example. Some obvious terms such as “great,” “excited,” or “really liked” are produced when the score sets 1. As the “joy” score gets lower and lower, the terms produced get more and more negative. When the score is set to 0, some negative terms, such as “nervous” or “not good” are produced. The second example shows the produced stories with various indicators from Plutchik. We assign various Plutchik indicators to “surprise,” “fear,” and “anger.” It produces several words, such as “was surprised” or “shocked” when Plutchik is “surprise.” When Plutchik is “fear,” the words “was afraid of” or “scared” are formed. The term “angry” can be formed when Plutchik is “anger.” In the third case, for the multiple Plutchik metrics, separate scores are assigned. In the third case, in the produced stories, several emotions are portrayed.Table 5
Examples of controllable generated stories.
Input sentenceJane bought a new necklace.CharacterJaneMaslowEsteem, loveReissApprovalGenerated stories with the same Plutchik indicator “joy” under different scoresJoy = 1Joy = 0.5Joy = 0Jane bought a new necklace.Jane bought a new necklace.Jane bought a new necklace.She was a great man.She was a new person; it was a bit huge.She was a person and it was a bit huge.Her friend was very excited.She was excited.The man was not good and she was very nervous.She really liked it.She always had been in the car, and it was fun.She was really wanted it; the baby was gone.She was very excited.She was really allowed to go to the beach.She was pulled in the car; It was gone.Generated stories with different Plutchik indicatorsSurprise = 1Fear = 1Anger = 1Jane bought a new necklace.Jane bought a new necklace.Jane bought a new necklace.She was surprised to see what she had been.She was nervous.She was nervous.The man was upset.She was nervous.She was angry about it.The man was shocked.She was afraid and was going to be scared.She tried to be a person; a man came into the car.The man was not friendly.She was going to the car that was very crowded.The man was pulled over the police’s car.Generated stories with multiple Plutchik indicatorsTrust = 1, joy = 0.5Sadness = 0.4, anticipation = 0.8Fear = 1, disgust = 0.5Jane bought a new necklace.Jane bought a new necklace.Jane bought a new necklace.The man was a nice man.She was very tired and she was not able to go.She was nervous.The man was very good and they were very good.She was nervous.She was afraid.The man was always had been in the car.She was nervous and her friends were not allowed to go.She was afraid and her friends were going to be scared.The man was very close in the car.She was nervous and decided to go to the party.She was nervous and went to the car; she was very scaredThe above examples demonstrate the controllability of our model. On the other hand, in the examples mentioned above, several incoherent stories tell us that although the model performs well in emotion control, it still needs to be improved in coherence.


## 5. Conclusion

Traditional story generation models can only generate stories with one specific emotion and lack coherence. In this paper, we propose a model called K-GuCCI, which can generate more vivid and coherent stories under controllable conditions. We take the three psychological state theories as our controllable conditions and design a character psychological state controller, which controls the psychological state of multiple characters in the story. We introduce the external knowledge graph to enhance the semantic and richness of stories. In addition, we design an evaluation metric called AGPS to evaluate the accuracy of the generated psychological state. For future work, we will use an advanced pretrained model to generate more coherent texts. In the field of wireless communications and mobile computing, there are many applications of the recommender system, such as [37–39], and the Internet technology, such as [40–42]. We want to use our method to recognize users’ emotions, generate high-quality text, and serve more Internet applications.



---

*Source: 5530618-2021-04-28.xml*