Story Ending Generation with Incremental Encoding and Commonsense Knowledge

Jian Guan, Yansen Wang, Minlie Huang

Introduction

Story generation is an important but challenging task because it requires to deal with logic and implicit knowledge (?; ?; ?; ?; ?; ?). Story ending generation aims at concluding a story and completing the plot given a story context. We argue that solving this task involves addressing the following issues: 1) Representing the context clues which contain key information for planning a reasonable ending; and 2) Using implicit knowledge (e.g., commonsense knowledge) to facilitate understanding of the story and better predict what will happen next.

Comparing to textual entailment or reading comprehension (?; ?) story ending generation requires more to deal with the logic and causality information that may span multiple sentences in a story context. The logic information in story can be captured by the appropriate sequence of eventsEvent in this paper refers to a verb or simple action such as dress up, trick or treating as shown in Figure 1. or entities occurring in a sequence of sentences, and the chronological order or causal relationship between events or entities. The ending should be generated from the whole context clue rather than merely inferred from a single entity or the last sentence. It is thus important for story ending generation to represent the context clues for predicting what will happen in an ending.

However, deciding a reasonable ending not only depends on representing the context clues properly, but also on the ability of language understanding with implicit knowledge that is beyond the text surface. Humans use their own experiences and implicit knowledge to help understand a story. As shown in Figure 1, the ending talks about candy which can be viewed as commonsense knowledge about Halloween. Such knowledge can be crucial for story ending generation.

Figure 1 shows an example of a typical story in the ROCStories corpus (?). In this example, the events or entities in the story context constitute the context clues which reveal the logical or causal relationships between events or entities. These concepts, including Halloween, trick or treat, and monster, are connected as a graph structure. A reasonable ending should consider all the connected concepts rather than just some individual one. Furthermore, with the help of commonsense knowledge retrieved from ConceptNet (?), it is easier to infer a reasonable ending with the knowledge that candy is highly related to Halloween.

To address the two issues in story ending generation, we devise a model that is equipped with an incremental encoding scheme to encode context clues effectively, and a multi-source attention mechanism to use commonsense knowledge. The representation of the context clues is built through incremental reading (or encoding) of the sentences in the story context one by one. When encoding a current sentence in a story context, the model can attend not only to the words in the preceding sentence, but also the knowledge graphs which are retrieved from ConceptNet for each word. In this manner, commonsense knowledge can be encoded in the model through graph representation techniques, and therefore, be used to facilitate understanding story context and inferring coherent endings. Integrating the context clues and commonsense knowledge, the model can generate more reasonable endings than state-of-the-art baselines.

To assess the machinery ability of story comprehension, we investigate story ending generation from two new angles. One is to modeling logic information via incremental context clues and the other is the utility of implicit knowledge in this task.

We propose a neural model which represents context clues by incremental encoding, and leverages commonsense knowledge by multi-source attention, to generate logical and reasonable story endings. Results show that the two techniques are effective in capturing the coherence and logic of story.

Related Work

The corpus we used in this paper was first designed for Story Cloze Test (SCT) (?), which requires to select a correct ending from two candidates given a story context. Feature-based (?; ?) or neural (?; ?) classification models are proposed to measure the coherence between a candidate ending and a story context from various aspects such as event, sentiment, and topic. However, story ending generation (?; ?; ?) is more challenging in that the task requires to modeling context clues and implicit knowledge to produce reasonable endings.

Story generation, moving forward to complete story comprehension, is approached as selecting a sequence of events to form a story by satisfying a set of criteria (?). Previous studies can be roughly categorized into two lines: rule-based methods and neural models. Most of the traditional rule-based methods for story generation (?; ?) retrieve events from a knowledge base with some pre-specified semantic relations.

Neural models for story generation has been widely studied with sequence-to-sequence (seq2seq) learning (?). And various contents such as photos and independent descriptions are largely used to inspire the story (?).To capture the deep meaning of key entities and events, ? (?) and ? (?) explicitly modeled the entities mentioned in story with dynamic representation, and ? (?) decomposed the problem into planning successive events and generating sentences from some given events. ? (?) adopted a hierarchical architecture to generate the whole story from some given keywords.

Commonsense knowledge is beneficial for many natural language tasks such as semantic reasoning and text entailment, which is particularly important for story generation. ? (?) characterized the types of commonsense knowledge mostly involved in recognizing textual entailment. Afterwards, commonsense knowledge was used in natural language inference (?; ?) and language generation (?). ? (?) incorporated external commonsense knowledge into a neural cloze-style reading comprehension model. ? (?) performed commonsense inference on people’s intents and reactions of the event’s participants given a short text. Similarly, ? (?) introduced a new annotation framework to explain psychology of story characters with commonsense knowledge. And commonsense knowledge has also been shown useful to choose a correct story ending from two candidate endings (?; ?).

Methodology

The task of story ending generation can be stated as follows: given a story context consisting of a sentence sequence X={X1,X2,⋯ ,XK}X=\{X_{1},X_{2},\cdots,X_{K}\}Adjacent sentences in story context have much logic connection, temporal dependency, and casual relationship., where Xi=x1(i)x2(i)⋯xli(i)X_{i}=x_{1}^{(i)}x_{2}^{(i)}\cdots x_{l_{i}}^{(i)} represents the ii-th sentence containing lil_{i} words, the model should generate a one-sentence ending Y=y1y2...ylY=y_{1}y_{2}...y_{l} which is reasonable in logic, formally as

As aforementioned, context clue and commonsense knowledge is important for modeling the logic and casual information in story ending generation. To this end, we devise an incremental encoding scheme based on the general encoder-decoder framework (?). As shown in Figure 2, the scheme encodes the sentences in a story context incrementally with a multi-source attention mechanism: when encoding sentence XiX_{i}, the encoder obtains a context vector which is an attentive read of the hidden states, and the graph vectors of the preceding sentence Xi−1X_{i-1}. In this manner, the relationship between words (some are entities or events) in sentence Xi−1X_{i-1} and those in XiX_{i} is built incrementally, and therefore, the chronological order or causal relationship between entities (or events) in adjacent sentences can be captured implicitly. To leverage commonsense knowledge which is important for generating a reasonable ending, a one-hop knowledge graph for each word in a sentence is retrieved from ConceptNet, and each graph can be represented by a vector in two ways. The incremental encoder not only attends to the hidden states of Xi−1X_{i-1}, but also to the graph vectors at each position of Xi−1X_{i-1}. By this means, our model can generate more reasonable endings by representing context clues and encoding commonsense knowledge.

Background: Encoder-Decoder Framework

The encoder-decoder framework is a general framework widely used in text generation. Formally, the model encodes the input sequence X=x1x2⋯xmX=x_{1}x_{2}\cdots x_{m} into a sequence of hidden states, as follows,

where ht\textbf{h}_{t} denotes the hidden state at step tt and e(x)\bm{e}(x) is the word vector of xx.

At each decoding position, the framework will generate a word by sampling from the word distribution P(yt∣y<t,X)\mathcal{P}(y_{t}|y_{<t},X) (y<t=y1y2⋯yt−1y_{<t}=y_{1}y_{2}\cdots y_{t-1} denotes the sequences that has been generated before step tt), which is computed as follows:

where st\textbf{s}_{t} denotes the decoder state at step tt. When an attention mechanism is applied, ct−1\textbf{c}_{t-1} is an attentive read of the context, which is a weighted sum of the encoder’s hidden states as ct−1=∑i=1mα(t−1)ihi\textbf{c}_{t-1}=\sum_{i=1}^{m}\alpha_{(t-1)i}\textbf{h}_{i}, and α(t−1)i\alpha_{(t-1)i} measures the association between the decoder state st−1\textbf{s}_{t-1} and the encoder state hi\textbf{h}_{i}. Refer to (?) for more details.

Incremental Encoding Scheme

Straightforward solutions for encoding the story context can be: 1) Concatenating the KK sentences to a long sentence and encoding it with an LSTM ; or 2) Using a hierarchical LSTM with hierarchical attention (?), which firstly attends to the hidden states of a sentence-level LSTM, and then to the states of a word-level LSTM. However, these solutions are not effective to represent the context clues which may capture the key logic information. Such information revealed by the chronological order or causal relationship between events or entities in adjacent sentences.

To better represent the context clues, we propose an incremental encoding scheme: when encoding the current sentence XiX_{i}, it obtains a context vector which is an attentive read of the preceding sentence Xi−1X_{i-1}. In this manner, the order/relationship between the words in adjacent sentences can be captured implicitly.

This process can be stated formally as follows:

where hj(i)\textbf{h}^{(i)}_{j} denotes the hidden state at the jj-th position of the ii-th sentence, e(xj(i))\bm{e}(x_{j}^{(i)}) denotes the word vector of the jj-th word xj(i)x_{j}^{(i)}. cl,j(i)\textbf{c}_{\textbf{l},j}^{(i)} is the context vector which is an attentive read of the preceding sentence Xi−1X_{i-1}, conditioned on hj−1(i)\textbf{h}^{(i)}_{j-1}. We will describe the context vector in the next section.

During the decoding process, the decoder obtains a context vector from the last sentence XKX_{K} in the context to utilize the context clues. The hidden state is obtained as below:

where clt\textbf{c}_{\textbf{l}t} is the context vector which is the attentive read of the last sentence XKX_{K}, conditioned on st−1\textbf{s}_{t-1}. More details of the context vector will be presented in the next section.

Multi-Source Attention (MSA)

The context vector (cl\textbf{c}_{\textbf{l}}) plays a key role in representing the context clues because it captures the relationship between words (or states) in the current sentence and those in the preceding sentence. As aforementioned, story comprehension sometime requires the access of implicit knowledge that is beyond the text. Therefore, the context vector consists of two parts, computed with multi-source attention. The first one chj(i)\textbf{c}_{\textbf{h}j}^{(i)} is derived by attending to the hidden states of the preceding sentence, and the second one cxj(i)\textbf{c}_{\textbf{x}j}^{(i)} by attending to the knowledge graph vectors which represent the one-hop graphs in the preceding sentence. The MSA context vector is computed as follows:

where ⊕\oplus indicates vector concatenation. Hereafter, chj(i)\textbf{c}_{\textbf{h}j}^{(i)} is called state context vector, and cxj(i)\textbf{c}_{\textbf{x}j}^{(i)} is called knowledge context vector.

The state context vector is a weighted sum of the hidden states of the preceding sentence Xi−1X_{i-1} and can be computed as follows:

where βhk,j(i)\beta_{h_{k},j}^{(i)} can be viewed as a weight between hidden state hj−1(i)\textbf{h}_{j-1}^{(i)} in sentence XiX_{i} and hidden state hk(i−1)\textbf{h}_{k}^{(i-1)} in the preceding sentence Xi−1X_{i-1}.

Similarly, the knowledge context vector is a weighted sum of the graph vectors for the preceding sentence. Each word in a sentence will be used as a query to retrieve a one-hop commonsense knowledge graph from ConceptNet, and then, each graph will be represented by a graph vector. After obtaining the graph vectors, the knowledge context vector can be computed by:

where g(xk(i−1))\textbf{g}(x_{k}^{(i-1)}) is the graph vector for the graph which is retrieved for word xk(i−1)x_{k}^{(i-1)}. Different from e(xk(i−1))\bm{e}(x_{k}^{(i-1)}) which is the word vector, g(xk(i−1))\textbf{g}(x_{k}^{(i-1)}) encodes commonsense knowledge and extends the semantic representation of a word through neighboring entities and relations.

During the decoding process, the knowledge context vectors are similarly computed by attending to the last input sentence XKX_{K}. There is no need to attend to all the context sentences because the context clues have been propagated within the incremental encoding scheme.

Knowledge Graph Representation

Commonsense knowledge can facilitate language understanding and generation. To retrieve commonsense knowledge for story comprehension, we resort to ConceptNethttps://conceptnet.io (?). ConceptNet is a semantic network which consists of triples R=(h,r,t)R=(h,r,t) meaning that head concept hh has the relation rr with tail concept tt. Each word in a sentence is used as a query to retrieve a one-hop graph from ConceptNet. The knowledge graph for a word extends (encodes) its meaning by representing the graph from neighboring concepts and relations.

There have been a few approaches to represent commonsense knowledge. Since our focus in this paper is on using knowledge to benefit story ending generation, instead of devising new methods for representing knowledge, we adopt two existing methods: 1) graph attention (?; ?), and 2) contextual attention (?). We compared the two means of knowledge representation in the experiment.

Formally, the knowledge graph of word (or concept) xx is represented by a set of triples, G(x)={R1,R2,⋯ ,RNx}\mathbf{G}(x)=\{R_{1},R_{2},\cdots,R_{N_{x}}\} (where each triple RiR_{i} has the same head concept xx), and the graph vector g(x)\bm{g}(x) for word xx can be computed via graph attention, as below:

where (hi,ri,ti)=Ri∈G(x)(h_{i},r_{i},t_{i})=R_{i}\in\mathbf{G}(x) is the ii-th triple in the graph. We use word vectors to represent concepts, i.e. hi=e(hi),ti=e(ti)\textbf{h}_{i}=\bm{e}(h_{i}),\textbf{t}_{i}=\bm{e}(t_{i}), and learn trainable vector ri\textbf{r}_{i} for relation rir_{i}, which is randomly initialized.

Intuitively, the above formulation assumes that the knowledge meaning of a word can be represented by its neighboring concepts (and corresponding relations) in the knowledge base. Note that entities in ConceptNet are common words (such as tree, leaf, animal), we thus use word vectors to represent h/r/t directly, instead of using geometric embedding methods (e.g., TransE) to learn entity and relation embeddings. In this way, there is no need to bridge the representation gap between geometric embeddings and text-contextual embeddings (i.e., word vectors).

Contextual Attention

When using contextual attention, the graph vector g(x)\textbf{g}(x) can be computed as follows:

where MRi\textbf{M}_{R_{i}} is the final state of a BiGRU connecting the elements of triple RiR_{i}, which can be seen as the knowledge memory of the ii-th triple, while h(x)\textbf{h}_{(x)} denotes the hidden state at the encoding position of word xx.

Loss Function

As aforementioned, the incremental encoding scheme is central for story ending generation. To better model the chronological order and causal relationship between adjacent sentences, we impose supervision on the encoding network. At each encoding step, we also generate a distribution over the vocabulary, very similar to the decoding process:

Then, we calculate the negative data likelihood as loss function:

Experiments

We evaluated our model on the ROCStories corpus (?). The corpus contains 98,162 five-sentence stories for evaluating story understanding and script learning. The original task is designed to select a correct story ending from two candidates, while our task is to generate a reasonable ending given a four-sentence story context. We randomly selected 90,000 stories for training and the left 8,162 for evaluation. The average number of words in X1/X2/X3/X4/YX_{1}/X_{2}/X_{3}/X_{4}/Y is 8.9/9.9/10.1/10.0/10.5 respectively. The training data contains 43,095 unique words, and 11,192 words appear more than 10 times. For each word, we retrieved a set of triples from ConceptNet and stored those whose head entity and tail entity are noun or verb, meanwhile both occurring in SCT. Moreover, we retained at most 10 triples if there are too many. The average number of triples for each query word is 3.4.

Baselines

We compared our models with the following state-of-the-art baselines:

Sequence to Sequence (Seq2Seq): A simple encoder-decoder model which concatenates four sentences to a long sentence with an attention mechanism (?).

Hierarchical LSTM (HLSTM): The story context is represented by a hierarchical LSTM: a word-level LSTM for each sentence and a sentence-level LSTM connecting the four sentences (?). A hierarchical attention mechanism is applied, which attends to the states of the two LSTMs respectively.

HLSTM+Copy: The copy mechanism (?) is applied to hierarchical states to copy the words in the story context for generation.

HLSTM+Graph Attention(GA): We applied multi-source attention HLSTM where commonsense knowledge is encoded by graph attention.

HLSTM+Contextual Attention(CA): Contextual attention is applied to represent commonsense knowledge.

Experiment Settings

The parameters are set as follows: GloVe.6B (?) is used as word vectors, and the vocabulary size is set to 10,000 and the word vector dimension to 200. We applied 2-layer LSTM units with 512-dimension hidden states. These settings were applied to all the baselines.

The parameters of the LSTMs (Eq. 5 and 6) are shared by the encoder and the decoder.

Automatic Evaluation

We conducted the automatic evaluation on the 8,162 stories (the entire test set). We generated endings from all the models for each story context.

We adopted perplexity(PPL) and BLEU (?) to evaluate the generation performance. Smaller perplexity scores indicate better performance. BLEU evaluates nn-gram overlap between a generated ending and a reference ending. However, since there is only one reference ending for each story context, BLEU scores will become extremely low for larger nn. We thus experimented with n=1,2n=1,2. Note also that there may exist multiple reasonable endings for the same story context.

Results

The results of the automatic evaluation are shown in Table 1The BLEU-2 results in the AAAI version is corrected in this version. Conclusions are not affected., where IE means a simple incremental encoding framework that ablated the knowledge context vector from cl\textbf{c}_{\textbf{l}} in Eq. (7). Our models have lower perplexity and higher BLEU scores than the baselines. IE and IE+MSA have remarkably lower perplexity than other models. As for BLEU, IE+MSA(CA) obtained the highest BLEU-1 and BLEU-2 scores. This indicates that multi-source attention leads to generate story endings that have more overlaps with the reference endings.

Manual Evaluation

Manual evaluations are indispensable to evaluate the coherence and logic of generated endings. For manual evaluation, we randomly sampled 200 stories from the test set and obtained 1,600 endings from the eight models. Then, we resorted to Amazon Mechanical Turk (MTurk) for annotation. Each ending will be scored by three annotators and majority voting is used to select the final label.

We defined two metrics - grammar and logicality for manual evaluation. Score 0/1/2 is applied to each metric during annotation.

Whether an ending is natural and fluent. Score 2 is for endings without any grammar errors, 1 for endings with a few errors but still understandable and 0 for endings with severe errors and incomprehensible.

Whether an ending is reasonable and coherent with the story context in logic. Score 2 is for reasonable endings that are coherent in logic, 1 for relevant endings but with some discrepancy between an ending and a given context, and 0 for totally incompatible endings.

Note that the two metrics are scored independently. To produce high-quality annotation, we prepared guidelines and typical examples for each metric score.

Results

The results of the manual evaluation are also shown in Table 1. Note that the difference between IE and IE+MSA exists in that IE does not attend to knowledge graph vectors in a preceding sentence, and thus it does use any commonsense knowledge. The incremental encoding scheme without MSA obtained the best grammar score and our full mode IE+MSA(GA) has the best logicality score. All the models have fairly good grammar scores (maximum is 2.0), while the logicality scores differ remarkably, much lower than the maximum score, indicating the challenges of this task.

More specifically, incremental encoding is effective due to the facts: 1) IE is significantly better than Seq2Seq and HLSTM in grammar (Sign Test, 1.84 vs. 1.74/1.571.74/1.57, p-value=0.046/0.0370.046/0.037, respectively), and in logicality (1.10 vs. 0.70/0.84, p-value<0.001/0.001<0.001/0.001). 2) IE+MSA is significantly better than HLSTM+MSA in logicality (1.26 vs. 1.06, p-value=0.0140.014 for GA; 1.24 vs. 1.02, p-value=0.0220.022 for CA). This indicates that incremental encoding is more powerful than traditional (Seq2Seq) and hierarchical (HLSTM) encoding/attention in utilizing context clues. Furthermore, using commonsense knowledge leads to significant improvements in logicality. The comparison in logicality between IE+MSA and IE (1.26/1.24 vs. 1.10, p-value=0.028/0.0420.028/0.042 for GA/CA, respectively), HLSTM+MSA and HLSTM (1.06/1.02 vs. 0.84, p-value<0.001/0.001<0.001/0.001 for GA/CA, respectively), and HLSTM+MSA and HLSTM+Copy (1.06/1.02 vs. 0.90, p-value=0.044/0.0480.044/0.048, respectively) all approve this claim. In addition, similar results between GA and CA show that commonsense knowledge is useful but multi-source attention is not sensitive to the knowledge representation scheme.

More detailed results are listed in Table 2. Comparing to other models, IE+MSA has a much larger proportion of endings that are good both in grammar and logicality (22-22). The proportion of good logicality (score=2.0) from IE+MSA is much larger than that from IE (45.0%+5.0%/41.0%+4.0% vs. 36.0%+2.0% for GA/CA, respectively), and also remarkable larger than those from other baselines. Further, HLSTM equipped with MSA is better than those without MSA, indicating that commonsense knowledge is helpful. And the kappa measuring inter-rater agreement is 0.29 for three annotators, which implies a fair agreement.

Examples and Attention Visualization

We presented an example of generated story endings in Table 3. Our model generates more natural and reasonable endings than the baselines.

In this example, the baselines predicted wrong events in the ending. Baselines (Seq2Seq, HLSTM, and HLSTM+Copy) have predicted improper entities (cake), generated repetitive contents (her family), or copied wrong words (eat). The models equipped with incremental encoding or knowledge through MSA(GA/CA) perform better in this example. The ending by IE+MSA is more coherent in logic, and fluent in grammar. We can see that there may exist multiple reasonable endings for the same story context.

In order to verify the ability of our model to utilize the context clues and implicit knowledge when planning the story plot, we visualized the attention weights of this example, as shown in Figure 3. Note that this example is produced from graph attention.

In Figure 3, phrases in the box are key events of the sentences that are manually highlighted. Words in blue or purple are entities that can be retrieved from ConceptNet, respectively in story context or in ending. An arrow indicates that the words in the current box (e.g., they eat in X2X_{2}) all have largest attention weights to some words in the box of the preceding sentence (e.g., cooking a special meal in X1X_{1}). Black arrows are for state context vector (see Eq.25) and blue for knowledge context vector (see Eq.26). For instance, eat has the largest knowledge attention to meal through the knowledge graph (<<meal, AtLocation, dinner>>,<<meal, RelatedTo, eat>>). Similarly, eat also has the second largest attention weight to cooking through the knowledge graph. For attention weights of state context vector, both words in perfects everything has the largest weight to some of everything to be just right (everything→\toeverything, perfect →\to right).

The example illustrates how the connection between context clues are built through incremental encoding and use of commonsense knowledge. The chain of context clues, such as be_cooking→want_everything_be_right→perfect_everything→lay_down→get_back{be\_cooking}\to{want\_everything\_be\_right}\to{perfect\_everything}\to{lay\_down}\to{get\_back}, and the commonsense knowledge, such as <<cook, AtLocation, kitchen>> and <<oven, UsedFor, burn>>, are useful for generating reasonable story endings.

Conclusion and Future Work

We present a story ending generation model that builds context clues via incremental encoding and leverages commonsense knowledge with multi-source attention. It encodes a story context incrementally with a multi-source attention mechanism to utilize not only context clues but also commonsense knowledge: when encoding a sentence, the model obtains a multi-source context vector which is an attentive read of the words and the corresponding knowledge graphs of the preceding sentence in the story context. Experiments show that our models can generate more coherent and reasonable story endings.

As future work, our incremental encoding and multi-source attention for using commonsense knowledge may be applicable to other language generation tasks.

Acknowledgements

This work was jointly supported by the National Science Foundation of China (Grant No.61876096/61332007), and the National Key R&D Program of China (Grant No. 2018YFC0830200). We would like to thank Prof. Xiaoyan Zhu for her generous support.

References

Appendix A: Annotation Statistics

We presented the statistics of annotation agreement in Table 4. The proportion of the annotations in which at least two annotators (3/3+2/3) assigned the same score to an ending is 96% for grammar and 94% for logicality. We can also see that the 3/3 agreement for logicality is much lower than that for grammar, indicating that logicality is more complicated for annotation than grammar.

Appendix B: Error Analysis

We analyzed error types by manually checking all 46 bad endings generated by our model, where bad means the average score in terms of at least one metric is not greater than 1.

There are 3 typical error types: bad grammar (BG), bad logicality (BL), and other errors. The distribution of types is shown in Table 5.

We also presented some typical cases for each error type in Table 6. Note that we only took graph attention as example. The first case shows an instance of bad grammar for repetitive generation. The second case shows that our model predicted a wrong entity at the last position where car is obviously more appropriate than daughter. It happens when the attention focuses on the wrong position, but in more cases it happens due to the noise of the commonsense knowledge baseNote that ConceptNet contains many low-quality triples.. The ending of the third case contains a relevant event work on his own but the event is not consistent to the previous word relieved. Other cases show that our model is not good at dealing with rare words. However, this can be further improved by applying copy mechanism, as our future work. These errors also indicate that story ending generation is challenging, and logic and implicit knowledge plays a central role in this task.

Appendix C: Attention Visualization

The multi-source attention mechanism computes the state context vectors and knowledge context vectors respectively as follows:

The visualization analysis in Section 4.6 “Generated Ending Examples and Attention Visualization” is based on the attention weights (αhk,j(i)\alpha_{h_{k,j}}^{(i)} and αxk,j(i)\alpha_{x_{k,j}}^{(i)}), as presented in Figure 4. Similarly we take as example the graph attention method to represent commonsense knowledge.

The figure illustrates how the incremental encoding scheme with the multi-source attention utilizes context clues and implicit knowledge. 1) The left column: for utilizing context clues, when the model encodes X2X_{2}, cooking in X1X_{1} obtains the largest state attention weight (αhk,j(i)\alpha_{h_{k,j}}^{(i)}), which illustrates cooking is an important word (or event) for the context clue. Similarly, the key events in each sentence have largest attention weights to some entities or events in the preceding sentence, which forms the context clue (e.g., perfects in X3X_{3} to right in X2X_{2}, lay/down in X4X_{4} to perfect/everything in X3X_{3}, get/back in YY to lay/down in X4X_{4}, etc.). 2) The right column: for the use of commonsense knowledge, each sentence has attention weights (αxk,j(i)\alpha_{x_{k,j}}^{(i)}) to the knowledge graphs of the preceding sentence (e.g. eat in X2X_{2} to meal in X1X_{1}, dinner in X3X_{3} to eat in X2X_{2}, etc.). In this manner, the knowledge information is added into the encoding process of each sentence, which helps story comprehension for better ending generation (e.g., kitchen in YY to oven in X2X_{2}, etc.).