Harnessing Machine Learning for Story Generation

In narrative generation, artificial intelligence (AI) methods like machine learning (ML) hold huge potential to revolutionize storytelling in diverse fields. These methods can be used to automatically create or contribute to stories that provide more engaging learning experiences. This article deliberates on the application of ML for story generation.

Study: Image credit: Pixels Hunter/Shutterstock
Image credit: Pixels Hunter/Shutterstock

Application of ML in Story Generation

Although automatic story generation is an age-old computational problem, the recent advances in ML are expected to accelerate this field's development. A recent wave of research has explored ML's potential for story generation. ML learns the conditional probability distribution between story events from a story corpus by considering the story as a sequence of events.

In this field of non-interactive textual story generation, most of the ML-related work can be characterized as script learning and generation, story completion, and story generation. In script learning and generation, a system learns to predict missing script events based on the script's other events, while in story completion, a system learns to generate missing events based on other story events.

The complete story is generated by the system in story generation. Most systems use recurrent neural networks (RNNs), which are successful in sequence-to-sequence (Seq2Seq) problems like dialogue systems and machine translation. For instance, RNN is trained to predict a story event based on other story events for story generation. RNN is also utilized to predict story sentences word by word based on language models.

Script Learning and Generation

Script learning and generation is the first step for generating stories using story corpora. This method determines to what extent a set of events and a given event are related. The temporal relationship between two events can be classified by focusing on the "before" relationship and training a support vector machine (SVM) for the temporal ordering of events. Thus, the system produces a ranked list of possible events that are suitable as part of the chain based on a given chain of events. Many studies used language models to predict events that involve compositional representations of events.

For instance, a log-bilinear model was trained for predicting story events to demonstrate that event prediction can be productively reframed as a language modeling task. The discriminative language model displayed better performance compared to the count-based methods.

Another study utilized long short-term memory (LSTM) RNN to statistically learn stories. The model predicted nouns or coreference information about event arguments. Specifically, the LSTM model was trained to predict the next element of the tuple given the preceding element by considering a story as a sequence of events abstracted as five-tuples, with the tuple's first element being predicted based on the previous tuple's last element. This model has demonstrated improved performance compared to baseline systems. A script learning model based on topical consistency, emotional trajectory, and event sequence was used that outperformed earlier approaches.

A study published at the Proceedings of the 26th International Joint Conference on Artificial Intelligence used generative adversarial networks (GANs) for script learning and generation, where the discriminative model discriminates the real sample from the fake sample, and the generative model generates a fake sample conditioned on the story context.

The discriminator possesses three models, including a bilinear model to calculate the target sentence and context document similarity, an attention-based LSTM-RNN model, and an LSTM-RNN model to represent the document and sentence, respectively.

Story Completion

Story completion involves completing the plot of a given story context. Most systems used for story completion conclude stories by generating a story ending depending on the previous story events. For instance, a study utilized the children's book test (CBT) dataset as a story corpus, and the story generation begins using an initial story containing 20 sentences as input and generating the next sentence based on case-based reasoning (CBR).

Subsequently, the RNN was used to generate the last sentence word-by-word by comparing it with the original 21st sentence. A context-aware hierarchical LSTM model has been developed to predict future subevents based on previous ones. Specifically, this model generates a sequence of words that describes the future subevent considering two event sequence levels, including the temporal sequence of events and the sequence of words, and the story topic as an additional contextual feature.

A Seq2Seq model was trained using adversarial training to generate diversified story endings. Although the traditional Seq2Seq models trained using only maximum likelihood estimation (MLE) are effective for generation tasks, every proper ending is acceptable in story-ending generation.

The generator creates story endings similar to endings written by humans to improve the generated ending quality. This is realized by training a discriminator/binary classifier to label the output as machine-generated or human-generated. The classification is utilized as a reward for the generator in the reinforcement learning (RL) algorithm.

The fluency and accuracy of the generated story endings were further improved by applying the copy and coverage mechanism to the conventional Seq2Seq model. The copy mechanism was used to directly generate story endings from previous story events through pointing to eliminate the out-of-vocabulary (OOV) problem. Additionally, the coverage mechanism was utilized to address the repetitive word problem by retaining a coverage vector that tracks the attention history to adjust future attention.

Moreover, a semantic relevance loss objective function was incorporated to maximize the semantic relevance between the story and the generated ending. The generator was trained using an RL algorithm that employs various evaluation metrics as reward functions to simulate the story generation process by humans.

Recently, a GPT-2-based model was proposed to generate an incomplete story's missing parts by conditioning the generated sentence on the next sentence and a previous sentence. This model created coherent stories adhering to the provided end. Another model adapted from the Transformer using shared attention layers for the decoder and encoder was used to generate the missing story plot at all positions for an incomplete story. Bidirectional encoder representations from the transformer (BERT) were utilized as the coherence discriminator.

Story Generation

An RNN model consisting of two sub-models, including RNN for story generator (RNNSG) and RNN encoder-decoder (RNNED), generated stories by predicting the next sentence. The RNNED maps a sentence/vector representation into a vector representation/sentence, while the RNNSG utilizes previously learned vectors for predicting the next vector in the vector sequence.

The RNN model employs vectorization to encode story sentences, subsequently utilizing these vectors for next-vector prediction. Then, the predicted vector is decoded into a sentence that represents the story's next sentence. Although the model generated sentences with correct overall content and grammar, it misused a few words in generated sentences. RNN was also utilized to guide Markov Chain Monte Carlo sampling in generating stories.

This involves transforming the natural language sentences into an event representation containing a verb, token, object, and subject and then predicting the next event in the story by considering a story as a Markov chain where the chain's every element is sampled from a distribution. Eventually, the predicted event is again translated into a natural language sentence.

A study published in the Proceedings of the Twenty-Eighth International Joint Conference on Artificial Intelligence presented a controllable RNN story generator inspired by planning-based story generation that accepts a given start and end/a start state and a final state. RL is employed to guide the RNN toward reaching the final state from the start state.

Specifically, the study used reward shaping, which is a method utilized in RL where the learning process is guided using transitional training rewards. The reward function is formulated based on the story-verb frequency component and the distance component after analyzing the story corpus.

However, RNNs lose the connection between the currently generated event and the previous far-off events as the story generation progresses. Its predictions depend on a small part of previous tokens, affecting the generated story's coherence and consistency.

Large-scale pre-trained language models like the GPT-2 model generate text comparable to human writings. However, these models can degenerate text by generating incoherent text or get stuck in repetitive loops, which is a major disadvantage.

Overall, ML techniques like RNNs, LSTMs, and GANs excel in automatic story generation. However, the limitations of these techniques and the general challenges of using ML, like lack of creativity and bias, must be addressed to use ML more extensively in narrative generation.

References and Further Reading

Alhussain, A. I., Azmi, A. M. (2021). Automatic story generation: a survey of approaches. ACM Computing Surveys (CSUR), 54(5), 1-38. https://doi.org/10.1145/3453156

Wang, B., Liu, K., Zhao, J. (2017). Conditional generative adversarial networks for commonsense machine comprehension. Proceedings of the 26th International Joint Conference on Artificial Intelligence, 4123-4129. https://www.researchgate.net/publication/318829808_Conditional_Generative_Adversarial_Networks_for_Commonsense_Machine_Comprehension

Tambwekar, P., Dhuliawala, M., Martin, L., Mehta, A., Harrison, B., Riedl, M. (2019). Controllable Neural Story Plot Generation via Reward Shaping. Proceedings of the Twenty-Eighth International Joint Conference on Artificial Intelligence, 5982-5988. https://doi.org/10.24963/ijcai.2019/829.

Last Updated: Feb 19, 2024

Samudrapom Dam

Written by

Samudrapom Dam

Samudrapom Dam is a freelance scientific and business writer based in Kolkata, India. He has been writing articles related to business and scientific topics for more than one and a half years. He has extensive experience in writing about advanced technologies, information technology, machinery, metals and metal products, clean technologies, finance and banking, automotive, household products, and the aerospace industry. He is passionate about the latest developments in advanced technologies, the ways these developments can be implemented in a real-world situation, and how these developments can positively impact common people.

Citations

Please use one of the following formats to cite this article in your essay, paper or report:

  • APA

    Dam, Samudrapom. (2024, February 19). Harnessing Machine Learning for Story Generation. AZoAi. Retrieved on November 23, 2024 from https://www.azoai.com/article/Harnessing-Machine-Learning-for-Story-Generation.aspx.

  • MLA

    Dam, Samudrapom. "Harnessing Machine Learning for Story Generation". AZoAi. 23 November 2024. <https://www.azoai.com/article/Harnessing-Machine-Learning-for-Story-Generation.aspx>.

  • Chicago

    Dam, Samudrapom. "Harnessing Machine Learning for Story Generation". AZoAi. https://www.azoai.com/article/Harnessing-Machine-Learning-for-Story-Generation.aspx. (accessed November 23, 2024).

  • Harvard

    Dam, Samudrapom. 2024. Harnessing Machine Learning for Story Generation. AZoAi, viewed 23 November 2024, https://www.azoai.com/article/Harnessing-Machine-Learning-for-Story-Generation.aspx.

Comments

The opinions expressed here are the views of the writer and do not necessarily reflect the views and opinions of AZoAi.
Post a new comment
Post

While we only use edited and approved content for Azthena answers, it may on occasions provide incorrect responses. Please confirm any data provided with the related suppliers or authors. We do not provide medical advice, if you search for medical information you must always consult a medical professional before acting on any information provided.

Your questions, but not your email details will be shared with OpenAI and retained for 30 days in accordance with their privacy principles.

Please do not ask questions that use sensitive or confidential information.

Read the full Terms & Conditions.