Auto Story Generator
Submitted in partial fulfillment of the requirements of the degree of
BACHELOR OF ENGINEERING
ARTIFICIAL INTELLIGENCE & DATA SCIENCE
by
Adepwar Krishna Raju, 12216037
Ayare Prachi Vilas, 12216010
Guide:
Dr. Anu Malhan
Department of Artificial Intelligence & Data Science
New Horizon Institute of Technology and Management, Thane
(2025-2026)
Table of Contents
Sr. No. Topic Page No.
1. Problem Definition 3
2. Introduction 4-5
3. Hardware & Software Requirements 6
4. Implementation details with screen-shots (stepwise) 7-10
5. References 11
Problem Definition
Storytelling is a significant part of human culture, education, and entertainment.
However, manually creating a coherent and engaging story requires substantial time,
effort, and creativity. This becomes challenging for individuals facing creative blocks,
educators who need fresh examples, and industries such as gaming and content creation
that require large volumes of narrative content.
The problem addressed by this project is the automatic generation of contextually
coherent short stories that combine creative storytelling with semantic relevance. Existing
automatic text generation systems often produce narratives that lack thematic
consistency, where characters, settings, and events may feel disconnected. This leads to
immersion-breaking and incoherent stories.
The Auto Story Generator aims to solve this by integrating semantic similarity analysis
(to ensure that story elements fit together meaningfully) with transformer-based natural
language generation (to produce fluent, human-like narratives). This combination ensures
that each generated story is both creative and logically consistent without requiring
manual input from the user.
Introduction
Storytelling has existed since the earliest days of human civilization, evolving from oral
traditions to written literature and, in modern times, to interactive and AI-generated
narratives. In the digital era, storytelling is not just a form of art but also a key element in
education, marketing, entertainment, and gaming. As artificial intelligence (AI) advances,
it has become possible to automate the creative writing process, allowing machines to
assist or even generate stories independently.
The Auto Story Generator is an innovative Natural Language Processing (NLP)
application designed to create short, engaging, and coherent stories with minimal human
intervention. It combines two main technologies:
1. Semantic Similarity Analysis using spaCy to ensure that all story elements—such
as characters, settings, events, and goals—are contextually aligned.
2. Transformer-based Text Generation using GPT-2, a large pre-trained deep
learning model capable of producing human-like narratives.
The process begins with predefined lists of story elements, including time periods,
locations, character archetypes, and plot events. The system randomly selects a main
setting and uses semantic similarity scoring to choose other elements that fit well within
the same thematic context. This curated set of elements forms a prompt, which is then
passed to the GPT-2 model to generate a complete story.
The purpose of this project is to assist creative writers, game developers, and educators
by providing a tool that can instantly generate unique storylines. By combining
rule-based semantic filtering with probabilistic language modeling, the Auto Story
Generator achieves a balance between creativity and logical narrative flow. This makes it
applicable in domains such as:
● Creative Writing Assistance: Helping authors brainstorm story ideas or overcome
writer’s block.
● Gaming: Dynamically generating quest narratives or background lore for
interactive games.
● Education: Teaching students about narrative structure by generating diverse
examples.
The significance of this work lies in its ability to demonstrate that AI can act as a
collaborator in creative work rather than a replacement for human creativity. The system
does not merely generate random stories; it produces them with a logical structure,
ensuring that all narrative elements contribute to a coherent whole.
Hardware & Software Requirements
● Operating System: Windows 10
● Programming Language: Python 3.8
● Python Libraries:
○ Flask – for backend web application development
○ spaCy – for semantic similarity analysis (en_core_web_md model)
○ Transformers (HuggingFace) – for GPT-2 implementation
○ Torch – deep learning framework for model execution
● Frontend Technologies: HTML, CSS, JavaScript
● Web Browser: Google Chrome
Implementation Details
The implementation of the Auto Story Generator is carried out in the following stages:
Step 1: Project Setup
● Install Python 3.8+ and required libraries using pip.
● Download the spaCy medium model (en_core_web_md) and GPT-2 model
weights.
● Create the folder structure for backend and frontend files.
Step 2: Backend Development with Flask
● Create a Flask API to handle story generation requests.
● Define an endpoint /generate-story that triggers the story creation process.
● Integrate spaCy and GPT-2 in the backend logic.
Step 3: Semantic Similarity Filtering
● Define lists of story elements (e.g., settings, characters, events).
● Use spaCy to compute similarity between the chosen main setting and other
elements.
● Select the most relevant elements based on similarity scores.
Step 4: Story Generation using GPT-2
● Load the GPT-2 model and pass the generated prompt as input.
● Set generation parameters (temperature=0.9, max_length=300, top_p=0.95) for
creative variation.
● Decode the output into readable text.
Step 6: Frontend Development
● Create an HTML interface with a "Generate Story" button.
● Use JavaScript to send a fetch request to the Flask backend and display the
generated story on the page.
References
1. Vaswani, A., Shazeer, N., Parmar, N., et al. (2017). Attention Is All You Need.
Advances in Neural Information Processing Systems.
2. Radford, A., Wu, J., Child, R., et al. (2019). Language Models are Unsupervised
Multitask Learners. OpenAI Technical Report.
3. spaCy Documentation – Industrial-strength Natural Language Processing in
Python. Available at: https://spacy.io
4. HuggingFace Transformers Documentation – State-of-the-art Natural Language
Processing. Available at: https://huggingface.co/transformers
5. Flask Documentation – Lightweight WSGI Web Application Framework.
Available at: https://flask.palletsprojects.com