SlowGuess/NAACL_2022_OCR huggingface dataset:
Zhexin Zhang; Jiaxin Wen; Jian Guan, Minlie Huang†
The CoAI group, DCST; Institute for Artificial Intelligence; State Key Lab of Intelligent Technology and Systems; Beijing National Research Center for Information Science and Technology; Tsinghua University, Beijing 100084, China.
{zx-zhang18，wenjx17，j-quan19}@mails.tsinghua.edu.cn
Endowing the protagonist with a specific personality is essential for writing an engaging story. In this paper, we aim to control the protagonist's persona in story generation, i.e., generating a story from a leading context and a persona description, where the protagonist should exhibit the specified personality through a coherent event sequence. Considering that personas are usually embodied implicitly and sparsely in stories, we propose a planning-based generation model named CONPER to explicitly model the relationship between personas and events. CONPER first plans events of the protagonist's behavior which are motivated by the specified persona through predicting one target sentence, then plans the plot as a sequence of keywords with the guidance of the predicted persona-related events and commonsense knowledge, and finally generates the whole story. Both automatic and manual evaluation results demonstrate that CONPER outperforms state-of-the-art baselines for generating more coherent and persona-controllable stories. Our code is available at https://github.com/thu-coai/ConPer.
Stories are important for entertainment. They are made engaging often by portraying animated and believable characters since a story plot unfolds as the characters interact with the object world created in the story (Young, 2000). Cognitive psychologists determined that the ability of an audience to comprehend a story is strongly correlated with the characters' believability (Graesser et al., 1991). And the believability mostly depends on whether the characters' reaction to what has happened and their deliberate behavior accord with their personas (e.g., weakness, abilities, occupations) (Madsen and Nielsen, 2009; Riedl and Young, 2010).
Context: Artur Boruc, a Polish national pilot, was going to get the group infiltrated into the area and prepared for the attack. Metal began to tear through the thin wings outside the small windows and pinged heavily off the underside of the plane, a quiet arrival in Poland wasn't going to be an option anymore.
Persona A: [Boruc] A skilled pilot, trained in operating flight controls on the most common planes.  
Generated Story by CONPER Conditioned on Persona A: …… He had been doing this much before, almost a week ago. He took a long pull of the airlock, checked his controls, and made a quick mental note of the exact sequence of instructions. He knew that he couldn't be sure if this would be safe for much longer…
Persona B: [Boruc] An unskilled pilot, and never trained in operat  
ging flight controls.  
Generated Story by CONPER Conditioned on Persona B: He  
cursed as the plane suffered a complete failure and in a way  
had caused it to come to a stop, ... He'd never flown before, so he  
didn't know how to pilot in this situation and his experience of the  
controls had not been good either...
Table 1: An example for controlling the protagonist's persona in story generation. The Context and Persona A are sampled from the STORIUM dataset (Akoury et al., 2020). The protagonist's name is shown in the square bracket. And we manually write Persona B based on Persona A. We highlight the sentences which embody the given personas in red.
Furthermore, previous studies have also stressed the importance of personas in stories to maintain the interest of audience and instigate their sense of empathy and relatedness (Cavazza et al., 2009; Chandu et al., 2019). However, despite the broad recognition of its importance, it has not yet been widely explored to endow characters with specified personalities in story generation.
In this paper, we present the first study to impose free-form controllable persona on story generation. Specifically, we require generation models to generate a coherent story, where the protagonist should exhibit the desired personality. We focus on controlling the persona of only the protagonist of a story in this paper and leave the modeling of personas of multiple characters for future work. As exemplified in Table 1, given a context to present the story settings including characters, location, problems (e.g., "Boruc" was suffering
Human Language Technologies, pages 3346 - 3361
from a plane crash) and a persona description, the model should generate a coherent story to exhibit the persona (e.g., what happened when "Boruc" was "skilled" or "unskilled"). In particular, we require the model to embody the personality of the protagonist implicitly through his actions (e.g., "checked his controls" for the personality "skilled pilot"). Therefore, the modeling of relations between persona and events is the first challenge of this problem. Then, we observe that only a small amount of events in a human-written story relate to personas directly and the rest serve for explaining the cause and effect of these events to maintain the coherence of the whole story. Accordingly, the second challenge is learning to plan a coherent event sequence (e.g., first "finding the plane shaking", then "checking controls", and finally "landing safely") to embody personas naturally.
In this paper, we propose a generation model named CONPER to deal with Controlling Persona of the protagonist in story generation. Due to the persona-sparsity issue that most events in a story do not embody the persona, directly fine-tuning on real-world stories may mislead the model to focus on persona-unrelated events and regard the persona-related events as noise (Zheng et al., 2020). Therefore, before generating the whole story, CONPER first plans persona-related events through predicting one target sentence, which should be motivated by the given personality following the leading context. To this end, we extract persona-related events that have a high semantic similarity with the persona description in the training stage. Then, CONPER plans the plot as a sequence of keywords to complete the cause and effect of the predicted persona-related events with the guidance of commonsense knowledge. Finally, CONPER generates the whole story conditioned on the planned plot. The stories are shown to have better coherence and persona-consistency than state-of-the-art baselines.
I. We propose a new task of controlling the personality of the protagonist in story generation.
II. We propose a generation model named CONPER to impose specified persona into story generation by planning persona-related events and a keyword sequence as intermediate representations.
III. We empirically show that CONPER can achieve better controllability of persona and generate more coherent stories than strong baselines.
Story Generation There have been wide explorations for various story generation tasks, such as story ending generation (Guan et al., 2019), story completion (Wang and Wan, 2019) and story generation from short prompts (Fan et al., 2018), titles (Yao et al., 2019) or beginnings (Guan et al., 2020). To improve the coherence of story generation, prior studies usually first predicted intermediate representations as plans and then generated stories conditioned on the plans. The plans could be a series of keywords (Yao et al., 2019), an action sequence (Fan et al., 2019; Goldfarb-Tarrant et al., 2020) or a keyword distribution (Kang and Hovy, 2020). In terms of character modeling in stories, some studies focused on learning characters' persona as latent variables (Bamman et al., 2013, 2014) or represented characters as learnable embeddings (Ji et al., 2017; Clark et al., 2018; Liu et al., 2020). Chandu et al. (2019) proposed five types of specific personas for visual story generation. Brahman et al. (2021) formulated two new tasks including character description generation and character identification. In contrast, we focus on story generation conditioned on personas in a free form of text to describe one's strengths, weaknesses, abilities, occupations and goals.
Controllable Generation Controllable text generation aims to generate texts with specified attributes. For example, Keskar et al. (2019) pretrained a language model conditioned on control codes of different attributes (e.g., domains, links). Dathathri et al. (2020) proposed to combine a pretrained language model with trainable attribute classifiers to increase the likelihood of the target attributes. Recent studies in dialogue models focused on controlling through sentence functions (Ke et al., 2018), politeness (Niu and Bansal, 2018) and conversation targets (Tang et al., 2019). For storytelling, Brahman et al. (2020) incorporated additional phrases to guide the story generation. Brahman and Chaturvedi (2020) proposed to control the emotional trajectory in a story by regularizing the generation process with reinforcement learning. Rashkin et al. (2020) generated stories from outlines of characters and events by tracking the dynamic plot states with a memory network.
A similar research to ours is Zhang et al. (2018), which introduced the PersonaChat dataset for endowing the chit-chat dialogue agents with a consis
Figure 1: Model overview of CONPER. The training process is divided into the following three stages: (a) Target Planning: planning persona-related events (called "target" for short); (b) Plot Planning: planning a keyword sequence as an intermediate representation of the story with the guidance of the target and a dynamically growing local knowledge graph; And (c) Story Generation: generating the whole story conditioned on the input and plans.
tent persona. However, dialogues in PersonaChat tend to exhibit the given personas explicitly (e.g., the agent says "I am terrified of dogs" for the persona "I am afraid of dogs"). For quantitative analysis, we compute the ROUGE score (Lin, 2004) between the persona description and the dialogue or story. We find that the rouge-2 score is 0.1584 for PersonaChat and 0.018 for our dataset (i.e., STORIUM). The results indicate that exhibiting personas in stories requires a stronger ability to associate the action of a character and his implicit traits compared with exhibiting personas in dialogues.
Commonsense Knowledge Recent studies have demonstrated that incorporating external commonsense knowledge significantly improved the coherence and informativeness for dialog generation (Zhou et al., 2018a; Zhong et al., 2020), story ending generation (Guan et al., 2019), essay generation (Yang et al., 2019), story generation (Guan et al., 2020; Xu et al., 2020; Mao et al., 2019) and story completion (Ammanabrolu et al., 2021). These studies usually retrieved a static local knowledge graph which contains entities mentioned in the input, and their related entities. We propose to incorporate the knowledge dynamically during generation to better model the keyword transition in a long-from story.
We define our task as follows: given a context  $X = (x_{1}, x_{2}, \dots, x_{|X|})$  with  $|X|$  tokens, and a persona description for the protagonist  $P = (p_{1}, p_{2}, \dots, p_{l})$  of length  $l$ , the model should generate a coherent story  $Y = (y_{1}, y_{2}, \dots, y_{|Y|})$  of
length  $|Y|$  to exhibit the persona. To tackle the problem, the popular generation model such as GPT2 commonly employ a left-to-right decoder to minimize the negative log-likelihood  $\mathcal{L}_{ST}$  of human-written stories:
$$
\mathcal {L} _ {S T} = - \sum_ {t = 1} ^ {| Y |} \log P \left(y _ {t} \mid y _ {<   t}, S\right), \tag {1}
$$
$$
P \left(y _ {t} \mid y _ {<   t}, S\right) = \operatorname {s o f t m a x} \left(\mathbf {s} _ {t} \boldsymbol {W} + \boldsymbol {b}\right), \tag {2}
$$
$$
\mathbf {s} _ {t} = \operatorname {D e c o d e r} \left(y _ {<   t}, S\right), \tag {3}
$$
where  $S$  is the concatenation of  $X$  and  $P$ ,  $\mathbf{s}_t$  is the decoder's hidden state at the  $t$ -th position of the story,  $\boldsymbol{W}$  and  $\boldsymbol{b}$  are trainable parameters. Based on this framework, we divide the training process of CONPER into three stages as shown in Figure 1.
3.1 Target Planning
We observe that most sentences in a human-written story do not aim to exhibit any personas, but serve to maintain the coherence of the story. Fine-tuning on these stories directly may mislead the model to regard input personas as noise and focus on modeling the persona-unrelated events which are in the majority. Therefore, we propose to first predict persona-related events (i.e., the target) before generating the whole story.
We use an automatic approach to extract the target from a story since there is no available manual annotation. Specifically, we regard the sentence as the target which has the highest semantic similarity with the persona description. We consider only one sentence as the target in this work due to the persona-sparsity issue, and we also present the
result of experimenting with two sentences as the target in the appendix B.1. More explorations of using multiple target sentences are left as future work. We adopt NLTK (Bird et al., 2009) for sentence tokenization. And we measure the similarity between sentences using BERTScoreRecall (Zhang et al., 2019) with RoBERTaLarge (Liu et al., 2019) as the backbone model. Let  $T = (\tau_{1},\tau_{2},\dots ,\tau_{\iota})$  denote the target sentence of length  $\iota$ , which should be a sub-sequence of  $Y$ . Formally, the loss function  $\mathcal{L}_{TP}$  for this stage can be derived as follows:
$$
\mathcal {L} _ {T P} = - \sum_ {t = 1} ^ {\iota} \log P \left(\tau_ {t} \mid \tau_ {<   t}, S\right). \tag {4}
$$
In this way, we exert explicit supervision to encourage the model to condition on the input personas.
3.2 Plot Planning
At this stage, CONPER learns to plan a keyword sequence for subsequent story generation (Yao et al., 2019). Plot planning requires a strong ability to model the causal and temporal relationship in the context for expanding a reasonable story plot (e.g., associating "unskilled" with "failure" for the example in Table 1), which is extremely challenging without any external guidance, for instance, commonsense knowledge. In order to plan a coherent event sequence, we introduce a dynamically growing local knowledge graph, a subset of the external commonsense knowledge base ConceptNet (Speer et al., 2017), which is initialized to contain triples related to the keywords mentioned in the input and target. When planning the next keyword, CONPER combines the knowledge information from the local graph and the contextualized features captured by the language model with learnable weights. Then CONPER grows the local graph by adding the knowledge triples neighboring the predicted keyword. Formally, we denote the keyword sequence as  $W = (w_{1}, w_{2}, \dots, w_{k})$  of length  $k$  and the local graph as  $\mathcal{G}_{t}$  for predicting the keyword  $w_{t}$ . The loss function  $\mathcal{L}_{KW}$  for generating the keyword sequence is as follows:
$$
\mathcal {L} _ {K W} = - \sum_ {t = 1} ^ {k} \log P \left(w _ {t} \mid w _ {<   t}, S, T, \mathcal {G} _ {t}\right). \tag {5}
$$
Keyword Extraction We extract words that relate to emotions and events from each sentence of a story as keywords for training, since they are important for modeling characters' evolving psychological states and their behavior. We measure
the emotional tendency of each word using the sentiment analyzer in NLTK, which predicts a distribution over four basic emotions, i.e., negative, neutral, positive, and compound. We regard those words as related to emotions whose scores for negative or positive are larger than 0.5. Secondly, we extract and lemmatize the nouns and verbs (excluding stopwords) from a story as event-related keywords with NLTK for POS-tagging and lemmatization. Then we combine the two types of keywords in the original order as the keyword sequence for planning. We limit the number of keywords extracted from each sentence in stories up to 5, and we ensure that there is at least one keyword for a sentence by randomly choosing one word if no keywords are extracted. We don't keep this limitation when extracting keywords from the leading context and the persona description, since these keywords are only used to initialize the local knowledge graph.
Incorporating Knowledge We introduce a dynamically growing local knowledge graph for plot planning. For each example, we initialize the graph  $\mathcal{G}_1$  as a set of knowledge triples where the keywords in  $S$  and  $T$  are the head or tail entities, and then update  $\mathcal{G}_t$  to  $\mathcal{G}_{t+1}$  by adding triples related with the generated keyword  $w_t$  at  $t$ -th step. Then, the key problem at this stage is representing and utilizing the local graph for next keyword prediction.
The local graph consists of multiple sub-graphs, each of which contains all the triples related with a keyword denoted as  $\varepsilon_{i} = \{(h_{n}^{i},r_{n}^{i},t_{n}^{i})|h_{n}^{i}\in \mathcal{V},r_{n}^{i}\in \mathcal{R},t_{n}^{i}\in \mathcal{V}\}\} |_{n = 1}^{N}$ , where  $\mathcal{R}$  and  $\mathcal{V}$  are the relation set and entity set of ConceptNet, respectively. We derive the representation  $\mathbf{g}_i$  for  $\varepsilon_{i}$  using graph attention (Zhou et al., 2018b) as follows:
$$
\mathbf {g} _ {i} = \sum_ {n = 1} ^ {N} \alpha_ {n} \left[ \mathbf {h} _ {n} ^ {i}; \mathbf {t} _ {n} ^ {i} \right] \tag {6}
$$
$$
\alpha_ {n} = \frac {\exp (\beta_ {n})}{\sum_ {j = 1} ^ {N} \exp (\beta_ {j})}, \tag {7}
$$
$$
\beta_ {n} = \left(\boldsymbol {W} _ {r} \mathbf {r} _ {n} ^ {i}\right) ^ {T} \tanh  \left(\boldsymbol {W} _ {h} \mathbf {h} _ {n} ^ {i} + \boldsymbol {W} _ {t} \mathbf {t} _ {n} ^ {i}\right), \tag {8}
$$
where  $\mathbf{W}_h, \mathbf{W}_r$  and  $\mathbf{W}_t$  are trainable parameters,  $\mathbf{h}_n^i, \mathbf{r}_n^i$  and  $\mathbf{t}_n^i$  are learnable embedding representations for  $h_n^i, r_n^i$  and  $t_n^i$ , respectively. We use the same BPE tokenizer (Radford et al., 2019) with the language model to tokenize the head and tail entities, which may lead to multiple sub-words for an entity.
Therefore, we derive  $\mathbf{h}_n^i$  and  $\mathbf{t}_n^i$  by adding the
embeddings of all the sub-words. And we initialize the relation embeddings randomly.
After obtaining the graph representation, we predict the distribution of the next keyword by dynamically deciding whether to select the keyword from the local graph as follows:
$$
P \left(w _ {t} \mid w _ {<   t}, S, T, \mathcal {G} _ {t}\right) = \gamma_ {t} P _ {k} ^ {t} + \left(1 - \gamma_ {t}\right) P _ {l} ^ {t}, (9)
$$
where  $\gamma_t \in \{0,1\}$  is a binary learnable weight, and  $P_l^t$  is a distribution over the whole vocabulary while  $P_k^t$  is a distribution over the entities in  $\mathcal{G}_t$ . We incorporate the knowledge information implicitly for computing both distributions:
$$
P _ {k} ^ {t} = \operatorname {s o f t m a x} \left(\boldsymbol {W} _ {k} \left[ \mathbf {s} _ {t}; \mathbf {c} _ {t} \right] + \boldsymbol {b} _ {k}\right), \tag {10}
$$
$$
P _ {l} ^ {t} = \operatorname {s o f t m a x} \left(\boldsymbol {W} _ {l} \left[ \mathbf {s} _ {t}; \mathbf {c} _ {t} \right] + \boldsymbol {b} _ {l}\right), \tag {11}
$$
where  $\pmb{W}_k, \pmb{b}_k, \pmb{W}_p$  and  $\pmb{b}_p$  are trainable parameters, and  $\mathbf{c}_t$  is a summary vector of the knowledge information by attending on the representations of all the sub-graphs in  $\mathcal{G}_t$ , formally as follows:
$$
\mathbf {c} _ {t} = \sum_ {n = 1} ^ {N} \alpha_ {n} \mathbf {g} _ {n}, \tag {12}
$$
$$
\alpha_ {n} = \operatorname {s o f t m a x} \left(\mathbf {s} _ {t} ^ {T} \boldsymbol {W} _ {g} \mathbf {g} _ {n}\right). \tag {13}
$$
where  $W_{g}$  is a trainable parameter. During training process, we set  $\gamma_{t}$  to the ground-truth label  $\hat{\gamma}_{t}$ . During generation process, we decide  $\gamma_{t}$  by deriving the probability  $p_t$  of selecting an entity from the local graph as the next keyword. And we set  $\gamma_{t}$  to 1 if  $p_t < 0.5$  otherwise 0. We compute  $p_t$  as follows:
$$
p _ {t} = \operatorname {s i g m o i d} \left(\boldsymbol {W} _ {p} \left[ \mathbf {s} _ {t}; \mathbf {c} _ {t} \right] + \boldsymbol {b} _ {p}\right), \tag {14}
$$
where  $\mathbf{W}_p$  and  $\mathbf{b}_p$  are trainable parameters. We train the classifier with the standard cross entropy loss  $\mathcal{L}_C$  derived as follows:
$$
\mathcal {L} _ {C} = - \left(\hat {\gamma} _ {t} \log p _ {t} + \left(1 - \hat {\gamma} _ {t}\right) \log \left(1 - p _ {t}\right)\right), \tag {15}
$$
where  $\hat{\gamma}_t$  is the ground-truth label. In summary, the overall loss function  $\mathcal{L}_{PP}$  for the plot planning stage is computed as follows:
$$
\mathcal {L} _ {P P} = \mathcal {L} _ {K W} + \mathcal {L} _ {C}. \tag {16}
$$
By incorporating commonsense knowledge for planning, and dynamically updating the local graph, CONPER can better model the causal and temporal relationship between events in the context.
Target Guidance In order to further improve the coherence and the persona-consistency, we propose to exert explicit guidance of the predicted target on plot planning. Specifically, we expect CONPER to predict keywords close to the target in semantics. Therefore, we add a bias term  $\mathbf{d}_k^t$  and  $\mathbf{d}_l^t$  into Equation 10 and 11, respectively, formally as follows:
$$
P _ {k} ^ {t} = \operatorname {s o f t m a x} \left(\boldsymbol {W} _ {k} \left[ \mathbf {s} _ {t}; \mathbf {c} _ {t} \right] + \boldsymbol {b} _ {k} + \mathbf {d} _ {k} ^ {t}\right), \tag {17}
$$
$$
\mathbf {d} _ {k} ^ {t} = \left[ \mathbf {s} _ {\text {t a r}}; \mathbf {c} _ {t} \right] ^ {T} \boldsymbol {W} _ {d} \mathbf {E} _ {k} + \boldsymbol {b} _ {d}, \tag {18}
$$
$$
\mathbf {s} _ {\text {t a r}} = \frac {1}{l} \sum_ {t = 1} ^ {l} \mathbf {s} _ {| \tau_ {t} |}, \tag {19}
$$
where  $\mathbf{W}_d$  and  $\mathbf{b}_d$  are trainable parameters,  $\mathbf{s}_{\mathrm{tar}}$  is the target representation computed by averaging the hidden states at each position of the predicted target, and  $\mathbf{E}_k$  is an embedding matrix, each row of which is the embedding for an entity in  $\mathcal{G}_t$ . The modification for Equation 11 is similar except that we compute the bias term  $\mathbf{d}_l^t$  with an embedding matrix  $\mathbf{E}_l$  for the whole vocabulary.
3.3 Story Generation
After planning the target  $T$  and the keyword sequence  $W$ , we train CONPER to generate the whole story conditioned on the input and plans with the standard language model loss  $\mathcal{L}_{ST}$ . Since we extract one sentence from a story as the target, we do not train CONPER to regenerate the sentence in the story generation stage. And we insert a special token Target in the story to specify the position of the target during training. In the inference time, CONPER first plans the target and plot, then generates the whole story, and finally places the target into the position of Target.
We conduct the experiments on the STORIUM dataset (Akoury et al., 2020). STORIUM contains nearly 6k long-form stories and each story unfolds through a series of scenes with several shared characters. A scene consists of multiple short scene entries, each of which is written to either portray one character with annotation for his personality (i.e., the "card" in STORIUM), or introduce new story settings (e.g., problems, locations) from the perspective of the narrator. In this paper, we concatenate all entries from the same scene since a scene can be seen as an independent story. And we regard a scene entry written for a certain character as the
target output, the personality of the character as the persona description, and the previous entries written for this character or from the perspective of the narrator in the same scene as the leading context. We split the processed examples for training, validation and testing based on the official split of STORIUM. We retain about 1,000 words (with the correct sentence boundary) for each example due to the length limit of the pretrained language model.