{'fraction_non_alphanumeric': 0.03547696396928529, 'fraction_numerical': 0.017387773183697577, 'mean_word_length': 4.586512683027428, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Pruned Graph Neural Network for Short Story Ordering

Text coherence is a fundamental problem in natural language generation and understanding. Organizing sentences into an order that maximizes coherence is known as sentence ordering. This paper is proposing a new approach based on the graph neural network approach to encode a set of sentences and learn orderings of short stories. We propose a new method for constructing sentence-entity graphs of short stories to create the edges between sentences and reduce noise in our graph by replacing the pronouns with their referring entities. We improve the sentence ordering by introducing an aggregation method based on majority voting of state-of-the-art methods and our proposed one. Our approach employs a BERT-based model to learn semantic representations of the sentences. The results demonstrate that the proposed method significantly outperforms existing baselines on a corpus of short stories with a new state-of-the-art performance in terms of Perfect Match Ratio (PMR) and Kendall's Tau (Tau) metrics. More precisely, our method increases PMR and Tau criteria by more than 5% and 4.3%, respectively. These outcomes highlight the benefit of forming the edges between sentences based on their cosine similarity. We also observe that replacing pronouns with their referring entities effectively encodes sentences in sentence-entity graphs.

In early studies, researchers modeled sentence structure using hand-crafted linguistic features (Lapata, 2003; Barzilay and Lee, 2004;Elsner et al., 2007;Barzilay and Lapata, 2008), nonetheless, these features are domain-specific. Therefore recent studies employed deep learning techniques to solve sentence ordering tasks (Golestani et al., 2021;Logeswaran et al., 2018;Gong et al., 2016;Li and Jurafsky, 2017;. (Cui et al., 2018) used graph neural networks, called ATTOrderNet, to accomplish this task. They used a self-attention mechanism combined with LSTMs to encode input sentences. Their method could get a reliable representation of the set of sentences regardless of their input order. In this representation, an ordered sequence is generated using a pointer network. Since ATTOrderNet is based on fully connected graph representations, it causes to build an association among some irrelevant sentences, which introduces massive noise into the network. Furthermore, since a self-attention mechanism only uses the information at the sentence level, other potentially helpful information such as entity information is missed.
To overcome these drawbacks, Yin et al. (2019) developed the Sentence-Entity Graph (SE-Graph), which adds entities to the graph. While in the AT-TOrderNet, every node is a sentence representation, SE-Graph consists of two types of nodes: sen-arXiv:2203.06778v1 [cs.CL] 13 Mar 2022 tence and entity 1 . Moreover, the edges come in two forms called SS and SE: • SS: this edge is between sentence nodes that share a common entity, • SE: this edge connects a sentence and an entity within the sentence labeled with the entity's role.
However, the introduced methods perform poorly for short story reordering tasks. The SE-graph solution seems effective for long texts but not for short stories. In this paper, we suggest modifications to the introduced graph methods to improve the performance for short story reordering tasks. Some issues arise in short stories: First, entities are often not repeated in multiple sentences in a short story or text; instead, pronouns refer to an entity. To address this problem, we improve the semantic graph by replacing the pronouns with their corresponding entities. Another issue is a high correlation between the sentences in a short story along with a high commonality of entities across sentences, which leads us to end up with a complete graph in most cases. Our solution is moving towards a Pruned Graph (PG). As with the ATTOrderNet and SE-Graph networks, the PG architecture consists of three components: 1. Sentence encoder based on SBERT-WK model (Wang and Kuo, 2020), 2. Graph-based neural story encoder, and 3. Pointer network based decoder.
With PG, the network nodes and SE edges are created based on SE-Graph, in a way that the first and third components are the same. However, in the story encoding phase, after generating the nodes and SE edges based on SE-Graph method, the pruning phase is started on SS edges. This pruning process is defined as follow: each sentence edged out its neighbors with the first and second most cosine similarities (Rahutomo et al., 2012). This method alleviates some problems of the previous two methods in the case of organizing short story sentences. It is noteworthy that pronouns are replaced with entities during pre-processing.
Finally, we present a method based on majority voting to combine our proposed graph networkbased method with the state-of-art methods to benefit from each. Contributions of this study are as follows: 1 the entity should be common to at least two sentences 1. Proposing a new method based on graph networks to order sentences of a short stories corpus by: (a) suggesting a new method for creating the edges between sentences, (b) creating a better sentence-entity graph for short stories by replacing pronouns in sentences with entities, (c) Moreover, taking advantage of BERTbased sentence encoder.
2. Using majority voting to combine sentence ordering methods.
2 Related Work

Sentence Ordering
In early studies on sentence ordering, the structure of the document is modeled using hand-crafted linguistic features (Lapata, 2003;Barzilay and Lee, 2004;Elsner et al., 2007;Barzilay and Lapata, 2008). Lapata (2003) encoded sentences as vectors of linguistic features and used data to train a probabilistic transition model. Barzilay and Lee (2004) developed the content model in which topics in a specific domain are represented as states in an HMM. Some other like Barzilay and Lapata (2008) utilize the entity-based approach, which captures local coherence by modeling patterns of entity distributions. Other approaches used a combination of the entity grid and the content model Elsner et al. (2007) or employed syntactic features (Louis and Nenkova, 2012) in order to improve the model. However, linguistic features are incredibly domain-specific, so applying these methods across different domains can decrease the performance. To overcome this limitation, recent works have used deep learning-based approaches. Li and Hovy (2014) proposes a neural model of distribution of sentence representations based on recurrent neural networks. In (Li and Jurafsky, 2017), graphbased neural models are used to generate a domainindependent neural model. Agrawal et al. (2016) introduced a method that involves combining two points elicited from the unary and pairwise model of sentences.  used an LSTM encoder and beam search to construct a pairwise model. Based on a pointer network that provides advantages in capturing global coherence, Gong et al. (2016) developed an end-to-end approach that predicts order of sentences. In another work, by applying an encoder-decoder architecture based on LSTMs and attention mechanisms, Logeswaran et al. (2018) suggested a pairwise model and established the gold order by beam search. In (Pour et al., 2020), we presented a method that does not require any training corpus due to not having a training phase. We also developed a framework based on a sentence-level language model to solve the sentence ordering problem in (Golestani et al., 2021). Moreover, in several other studies, including (Cui et al., 2018) and (Yin et al., 2019), graph neural networks are used to accomplish this task, as explained in the following.
In particular, text classification is a common application of GNNs in natural language processing. A GNN infers document labels based on the relationships among documents or words (Hamilton et al., 2017). Christensen et al. (2013) used a GNN in multi-document summarization. They create multi-document graphs which determine pairwise ordering constraints of sentences based on the discourse relationship between them. Kipf and Welling (2017) proposed Graph Convolutional Networks (GCN), which is used in Yasunaga et al. (2017) to generate sentence relation graphs. The final sentence embeddings indicate the graph representation and are utilized as inputs to achieve satisfactory results on multi-document summarization.
Another method is presented in Marcheggiani and Titov (2017) where a syntactic GCN is developed with a CNN/RNN as sentence encoder. The GCN indicates syntactic relations between words in a sentence. In a more recent work, Yin et al. (2019) proposed a graph-based neural network for sentence ordering, in which paragraphs are modeled as graphs where sentences and entities are the nodes. The method showed improvement in evaluation metrics for sentence ordering task. In this work, we explore the use of GRN for NLP tasks, es-pecially to perform sentence-ordering on a corpus of short stories.

Baselines
This section introduces ATTOrderNet (Cui et al., 2018) and SE-Graph (Yin et al., 2019), which achieve state-of-the-art performances and serve as baseline for our work.

ATTOrderNet
ATTOrderNet introduced in (Cui et al., 2018) is a model using graph neural networks for sentence ordering. The model includes three components as follows: a sentence encoder based on Bi-LSTM, a paragraph encoder based on self-attention, and a pointer network-based decoder. In the sentence encoder, sentences are translated into distributional representations with a word embedding matrix. Then a sentence-level representation using the Bi-LSTM is learned. An average pooling layer follows multiple self-attention layers in the paragraph encoder. The paragraph encoder computes the attention scores for all pairs of sentences at different positions in the paragraph. Therefore, each sentence node is connected to all others where the encoder exploits latent dependency relations among sentences independent of their input order.
Having an input set of sentences, the decoder aims to predict a coherent order, identical to the original order. In this method, LSTM-based pointer networks are used to predict the correct sentence ordering from the final paragraph representation. Based on the sequence-to-sequence model, the pointer network-based decoders predict the correct sentence sequence (Sutskever et al., 2014). Specifically, input tokens are encoded using the pointer network as summary vectors 2 , and the next token vector is decoded repeatedly. Finally, the output token sequence is derived from the output token vector.

SE-Graph
SE-Graph, similarly to ATTOrderNet, consists of three components: 1. a sentence encoder based on Bi-LSTM, 2. a paragraph encoder, 3. a pointer network based decoder Nevertheless, the difference between SE-Graph and ATTOrderNet is only in the encoder paragraph component, described in the following. In contrast to the fully connected graph representations explored by ATTOrderNet, Yin et al. (2019) represented input paragraphs as sentence-entity graphs. The SE-Graph includes two types of nodes: sentence and entity. The entity should be common to at least two sentences to be considered as a node of the graph. There are also two types of edges: SS edges that connect sentence nodes with at least a common entity, and SE edges that link a sentence with an entity within that and with a label of the entity's role. SE edges are labeled based on the syntactic role of the entity in the sentence, such as a subject, an object, or other. When an entity appears multiple times in a sentence with different roles, the role that has the highest rank is considered. The highest rank of roles is the subject role; after that are the object roles. SE-Graph framework utilizes a GRN-based paragraph encoder that integrates the paragraphlevel state along with the sentence-level state.

Methodology
In this section, first, the problem is formulated, second the dataset is introduced and explains why this dataset is suitable for the sentence ordering task. Then two methodologies are proposed. The first proposed method, called Pruned Graph, is based on graph networks, and the second is based on the majority voting to combine the outputs of three different models.

Problem Formulation
Consider S(O) is a set of n unordered sentences taken from a coherent text: O = s 1 , s 2 , . . . , s n , The goal of sentence ordering is to find a permutation of sentences of O like S(o ), that corresponds to the gold data arrangement. In other words, sentence ordering aims to restore the original orders: Where S(o * ) represents the original or gold order. As a result a correct output leads to S(o ) = S(o * ). Based on the above definition and notions we propose our sentence ordering method.

Dataset
In this paper, we used a corpus of short stories, called ROCStories (Mostafazadeh et al., 2016). It contains 98,162 commonsense stories, each with exactly five sentences and an average word count of 50. Mostafazadeh et al. (2017) created ROCStories corpus for a shared task called LSDSem, in which models are supposed to predict the correct ending to short stories. 3,742 of the stories have two options for the final sentence. It is worth noting that humans generated all of the stories and options.
We can learn sequences of daily events from this dataset because it contains some essential characteristics: The stories are rich with causal and temporal relations among events, which makes this dataset a highly useful resource for learning narrative structure across a wide range of events. The dataset consists of a comprehensive collection of daily and non-fictional short stories useful for modeling the coherence of a text (Mostafazadeh et al., 2016).
Due to these features, ROCStories can be used to learn sequences of sentences. Thus, the corpus is useful for organizing sentences in a text.

Pruned Graph Sentence Ordering (PG)
We propose a neural network based on the pruned graph for arranging the sentences of short stories, a modified version of the ATTOrderNet (Cui et al., 2018) and Sentence-Entity Graph (Yin et al., 2019). The PG method consists of three components: sentence encoder, story encoder, and decoder. In order to be a fair comparison, we used the same decoder as ATTOrderNet and SE-Graph. Due to space limitations, here we explain our sentence encoder and our story encoder. The Sentence encoder uses BERT encoding to encode sentences, while Story encoder uses a graph neural network for encoding stories.

Sentence Encoder: SBERT-WK
We use fine-tuned pre-trained SBERT-WK model to encode sentences. BERT contains several layers, each of which captures a different linguistic characteristic. SBERT-WK found better sentence representations by fusing information from different layers, Wang and Kuo (2020). The system geometrically analyzes space using a deep contextual model that is trained on both word-level and sentence-level, without further training. For each word in a sentence, it determines a unified word representation then computes the final sentence embedding vector based on the weighted average based on the word importance of the word representations. Even with a small embedding size of 768, SBERT-WK outperforms other methods by a significant margin on textual similarity tasks (Wang and Kuo, 2020).

Story Encoder
To use graph neural networks for encoding stories, input stories should be represented as graphs. We propose a pruned graph (PG) representation instead of SE-Graph (Yin et al., 2019) for encoding short stories. Nodes in PG are composed of sentences and entities. We replace pronouns with the entities they refer to since entities are not often repeated from one sentence to another during a short story 3 , we will go into more detail in the experiments. We consider all nouns of an input story as entities at first. After that, we eliminate entities that do not occur more than once in the story.
We can formalize our undirected pruned graphs as G = (V s , V e , E), where V s indicates the sentencelevel nodes, V e denotes the entity-level nodes, and E represents edges. Edges in PG graphs are divided into two types: SS and SE. The SS type links two sentences in a story that have the highest or secondhighest value of cosine similarity with each other; and the SE type links a sentence with an entity within that with a label of the entity's role. Equation 4 shows the formula for calculating the cosine similarity, where CosSim is cosine similarity and Emb s i represents vector of sentence i.

CosSim(Emb s i , Emb s j ) =
Emb s i * Emb s j ||Emb s i ||||Emb s j || (4) SE edges are labeled according to the syntactic role of the entity in the sentence, such as a subject, an object, or other. The role that has the highest rank in an instance of an entity appearing multiple times is considered. The ranking is as follows: subject role, object roles, and other. The use of referring entities rather than pronouns is crucial.
Thus, sentence nodes are linked to both sentence and entity nodes, whereas an entity node is not connected to any other entity nodes. For graph encoding, we use GRN , which has been found effective for various kinds of graph encoding tasks. GRN used in our PG is the same 3 we use the Stanford's tool (Lee et al., 2011) as GRN in (Yin et al., 2019), so we do not explain it.

Majority Voting
We combine the output of three methods to achieve better results in majority voting. Since the stories in Rocstories all have five sentences, there are 20 possible pair sentence orderings as follow: 1. s 1 s 2 or 2. s 2 s 1 , 3. s 1 s 3 or 4. s 3 s 1 , 5. s 1 s 4 or 6. s 4 s 1 , 7. s 1 s 5 or 8. s 5 s 1 , 9. s 2 s 3 or 10. s 3 s 2 , 11. s 2 s 4 or 12. s 4 s 2 , 13. s 2 s 5 or 14. s 5 s 2 , 15. s 3 s 4 or 16. s 4 s 3 , 17. s 3 s 5 or 18. s 5 s 3 , 19. s 4 s 5 or 20. s 5 s 4 Each suggested order for a story includes 10 of the above pair orderings, either of the two pair orderings that have an "or" between them. Through majority voting 4 , we can combine the outputs of three separate methods to generate a final order.
According to the number of occurrences in each of the three output arrangements, we assign scores to each of the 20 possible pairings. As a result, each of these possible pairings is scored between 0 and 3. 0 indicates that this pairing does not appear in any of the three methods' outputs, while 3 indicates that it appears in all of them. In the end, all pairs with a greater score of 1 occur in the final orderings 5 . Indeed, these are ten pairs 6 , and with the chosen pairs, the sentences of the story are arranged uniquely.
In the following subsection, we are proving that majority voting is a valid way to combine the outputs generated from three different methods for arranging sentences. By using contradiction, we demonstrate the validity of the majority voting method for combining three distinct methods of sentence ordering to arrange two sentences.
Assuming the majority voting of three methods fails to create an unique order, then two orders are possible, s 1 s 2 , and s 2 s 1 . In the first case, s 1 appears before s 2 in two or more outputs of the methods, and in the second case, s 2 appears before s 1 in two or more outputs. Due to the three methods, this assumption causes a contradiction. To ordering more than two sentences, it can be proved by induction.

Evaluation Metrics
We use two standard metrics to evaluate the proposed model outputs that are commonly used in previous work: Kendall's tau and perfect match ratio, as described below.
• Kendall's Tau (τ ) Kendal's Tau (Lapata, 2006) measures the quality of the output's ordering, computed as follows: Where N represents the sequence length (i.e. the number of sentences of a story, which is always equal to 5 for ROCStories), and the inversions return the number of exchanges of the predicted order with the gold order for reconstructing the correct order. τ is always between -1 and 1, where the upper bound indicates that the predicted order is exactly the same as the gold order. This metric correlates reliably with human judgments, according to Lapata (2006).

• Perfect Match Ratio (PMR)
According to this ratio, each story is considered as a single unit, and a ratio of the number of correct orders is calculated. Therefore no penalties are given for incorrect permutations (Gong et al., 2016). PMR is formulated mathematically as follows: where o i represents the output order and o * i indicates the gold order. N specifies the sequence length. Since the length of all the stories of ROCStories is equal to 5, N in this study is always equal to 5. PMR values range from 0 to 1, with a higher value indicating better performance.
In (Golestani et al., 2021), we developed the Sentence-level Language Model (SLM) for Sentence Ordering, consisting of a Sentence Encoder, a Story Encoder, and a Sentence Organizer. The sentence encoder encodes sentences into a vector using a fine-tuned pre-trained BERT. Hence, the embedding pays more attention to the sentence's crucial parts. Afterward, the story encoder uses a decoder-encoder architecture to learn the sentencelevel language model. The learned vector from the hidden state is decoded, and this decoded vector is utilized to indicate the following sentence's candidate. Finally, the sentence organizer uses the cosine similarity as the scoring function in order to sort the sentences.
An attention-based ranking framework is presented in (Kumar et al., 2020) to address the task. The model uses a bidirectional sentence encoder and a self-attention-based transformer network to endcode paragraphs. In (Yin et al., 2020), an enhancing pointer network based on two pairwise ordering prediction modules, The FUTURE and HISTORY module, is employed to decode paragraphs. Based on the candidate sentence, the FU-TURE module predicts the relative positions of other unordered sentences. Although, the HIS-TORY module determines the coherency between the candidate and previously ordered sentences. And lastly, Prabhumoye et al. (2020) designed B-TSort, a pairwise ordering method, which is the current state-of-the-art method for sentence ordering. This method benefits from BERT and graph-based networks. Based on the relative pairwise ordering, graphs are constructed. Finally, the global order is derived by a topological sort algorithm on the graph.

Setting
For a fair comparison, we follow Yin et al. (2019)'s settings. Nevertheless, we use SBERT-WK's 768dimension vectors for sentence embedding. Furthermore, the state sizes for sentence nodes are set to 768 in the GRN; The Batch size is 32. In preprocessing, we use Stanford's tool (Lee et al., 2011) to replace pronouns with the referring entities.

Results
In this paper, we propose a new method based on graph networks for sentences ordering short stories called Pruned Graph (PG). In order to achieve this, we propose a new method for creating edges between sentences (by calculating the cosine similarity between sentences), and we create a better sentence-entity graph for short stories by replacing pronouns with the relevant entities. Besides, to make a better comparison, we also teach the following cases: 1. All nodes in the graph are of the sentence type, and the graph is fully connected. In other words, we train ATTOrderNet on ROC-Stories 7 .
2. The nodes include sentence and entity nodes, and each sentence's node has the edge over all other sentences' nodes (semi fully connected SE-Graph 8 ).
3. The network comprises sentence and entity nodes, and every two sentences with at least one entity in common are connected (SE-Graph 9 ). 7 (Cui et al., 2018) did not train ATTOrderNet on the ROC-Stories dataset. 8 Entity nodes are not connected to all nodes. 9 We train SE-Graph on ROCStories since (Yin et al., 2019) did not.

Replacing pronouns with the relevant entities
in SE-Graph (SE-Graph + Co-referencing).
5. Similar to PG, but each sentence is connected to a sentence with the highest cosine similarity (semi P G 1 ).
6. Similar to PG; however, each sentence is connected to three other sentences based on their cosine similarity (semi P G 3 ).
Note that in the above methods, where the graph also contains the nodes of the entity, there is an edge between a sentence and an entity within it 11 . Table 1 reports the results of Pruned Graph (PG) and the above seven methods.
To get the training, validation, and testing datasets, we randomly split ROCStories into 8:1:1. Therefore, the training set includes 78,529 stories, the validation set contains 9,816 stories, and the testing set consists of 9,817 stories.
As shown in table 1, our PG beats all seven other methods. The results show that all three of our innovations to the graph-based method have improved the performance. Based on our analysis, the SBERT-WK sentence encoder is more beneficial than the Bi-LSTM. Our experiences also find that using referring entities instead of pronouns is helpful to create a more effective sentence-entity graph. Additionally, it indicates connecting each sentence to two others using cosine similarity is efficient to encode a story. Table 2 reports the results of the proposed method of this paper in comparison with competitors. When compared with ATTOrdeNet, PG improved the Tau by over 8.5% as well as PMR by 13.5%. Furthermore, the Tau is increased by 10.8% and the PMR by more than 16.8% compared to SE-Graph. PG outperforms the state-of-the-art on ROCStories with a more tthan 1.8% increase in pmr and a more than 3.9% improvement in τ .
Finally, we merged the outputs of the three methods using the majority voting method, including Enhancing PtrNet, B-TSort, and Our Pruned Graph. Table 3 shows the results of the combination, which improves the PMR and τ criteria by more than 5% and 4.3% on ROCStories, respectively.

conclusion
This paper introduced a graph-based neural framework to solve the sentence ordering task. This framework takes a set of randomly ordered sentences and outputs a coherent order of the sentences. The results demonstrate that SBERT-WK is a reliable model to encode sentences. Our analysis examined how the method is affected by using a Bi-LSTM model in the sentence encoder component. In addition, we found that replacing pronouns with their referring entities supplies a more informative sentence-entity graph to encode a story. The experimental results indicate that our proposed graph-based neural model significantly outperforms on ROCStories dataset. Furthermore, we recommend a method for combining different Method τ PMR combination 0.8470 0.5488 Table 3: Results of combining of Enhancing PtrNet, B-TSort, and Pruned Graph using majority voting methods of sentence ordering based on majority voting that achieves state-of-the-art performance in PMR and τ scores. In future, we plan to apply the trained model on sentence ordering task to tackle other tasks including text generation, dialogue generation, text completion, retrieval-based QA, and extractive text summarization.