Case study · M.Tech · NLP & GenAI

Interactive storytelling AI using LLMs

This interactive storytelling AI project, built on LLMs, is a delivered M.Tech generative AI and NLP system: the reader answers guided questions about setting, characters, theme and plot, and a FastAPI backend turns the answers into a personalised story that continues through the reader’s choices.

Last updated

IEEE-format two-column results page from the interactive storytelling AI paper, with charts for latency by LLM provider, token usage by genre, end-to-end timing, user satisfaction and consistency-check performance.
IEEE-format paper
Question step in the interactive storytelling web app: the user picks the story’s world from guided options or writes their own answer.
Web app
Radar chart comparing this interactive storytelling system with AI Dungeon, Dramatron and NovelAI across seven dimensions.
Results

From this delivered M.Tech project, shown with names and institute details removed. Select an image to zoom.

Each chapter gets an AI-generated illustration, spoken narration and genre-matched ambient music, and any of four LLM providers (local Ollama, Groq, Hugging Face or OpenAI) can write the text. The student received the web app and code, an IEEE-format paper, a longer single-column paper and a full dissertation.

What is this project, at a glance?

The interactive storytelling AI in six lines
ItemDetails
LevelM.Tech
DomainGenerative AI, natural language processing
Problem typePersonalised, controllable story generation (human–AI co-creation)
Core methodsGuided Q&A to capture preferences; keyword and pattern-based context extraction; genre- and phase-aware prompt templates; a five-phase story arc; character and plot-thread tracking with consistency checks; a provider-agnostic LLM layer
StackPython, FastAPI and Uvicorn, Pydantic, SQLite; HTML, CSS, JavaScript and D3.js; Ollama, Groq, Hugging Face and OpenAI models; an AI image service, browser speech synthesis and ambient music
DeliverablesWeb app and source code, IEEE-format paper, single-column research paper, M.Tech dissertation in LaTeX, result figures, presentation slides

What problem does this AI story generator project solve?

Most AI story tools take a single prompt and return a block of text. The reader has little say in what happens, and in longer sessions the model tends to forget characters, drop plot threads or lose its pacing. Many tools also depend on one paid API.

The literature review found that existing systems lean one way or the other: open-ended tools such as AI Dungeon give freedom but lose coherence, while structured tools such as Dramatron keep coherence but offer less interaction. This project combines both, and runs on free or local models.

How does the system turn answers into a story?

The backend is a pipeline of seven modules, each with one job:

  1. Question flow. Guided questions cover setting, characters, theme and plot. Each offers ready options or a free-text answer, and the reader chooses how many questions to answer, from a quick set to the full one.
  2. Context extraction. Keyword maps and regular expressions turn the answers into a structured story context: genre, setting, characters and conflict.
  3. Memory. SQLite stores sessions, answers, story segments and context, so each continuation sees what came before.
  4. Prompt engineering. Templates change with genre, tone and the current story phase, and a sliding window of recent exchanges keeps prompts within the model’s limit.
  5. Story generator. One interface wraps four LLM providers, with switching at runtime and automatic fallback.
  6. Story flow manager. A five-phase arc based on Freytag’s pyramid (introduction, rising action, climax, falling action, resolution) moves the story on by length, while trackers watch characters and plot threads for contradictions and loose ends.
  7. Output formatter. Cleans and paragraphs the text and exports it as TXT, Markdown or styled HTML.
Layered architecture of the interactive storytelling AI: an HTML, CSS, JavaScript and D3.js front end; a FastAPI application layer; pipeline modules for input, context extraction, prompt engineering, story flow and SQLite memory; image, speech and audio services; and Ollama, Groq, Hugging Face and OpenAI model providers.
ArchitectureLayered architecture: web front end, FastAPI backend with story-pipeline modules, image/voice/audio services and pluggable LLM providers (Ollama, Groq, Hugging Face, OpenAI).

Three media services sit on top of the text pipeline. A scene description extracted from each chapter drives an AI illustration, the browser’s speech synthesis reads the chapter aloud, and each genre has its own ambient music preset.

What did we build?

The front end is plain HTML, CSS and JavaScript served by FastAPI, so it runs without a build step. A reader can:

  • answer the questions or write their own answers, with progress shown as they go;
  • read each chapter with its illustration, listen to the narration, and continue by picking one of the generated choices;
  • explore a story map and a character-relationship graph drawn with D3.js;
  • switch LLM provider and model in settings, bookmark a story and export it.
World-building question in the storytelling app, asking where the story should take place, with five ready answers and a Write my own option.
Web appWeb app Q&A step: the user picks the story’s world from guided options or writes their own answer.
Story reader screen of the LLM story app showing Chapter 1, with an AI-generated fantasy character illustration above the opening paragraphs of the generated story.
Web appStory reader screen: a generated chapter with an AI-generated illustration and narrative text.

The dissertation also documents unit, integration, API and end-to-end tests, including how the app behaves when the image service fails.

How was it evaluated, and what did the results show?

The system was tested on stories generated across several genres and in a small user study, where participants created stories and rated them on Likert scales. The paper reports response time per LLM provider, narrative quality by genre, user satisfaction and how well the consistency checker caught problems.

  • Speed depends on where the model runs. Hosted free-tier models answered fastest; a local Ollama model was slowest but needs no internet or API key.
  • Custom answers and the chapter illustrations rated highest. The usefulness of the continuation choices rated lowest, and the paper names it as a limitation of free-tier models.
  • The consistency checker was most reliable on character contradictions and weakest on tone shifts, which simple keyword matching struggles to detect.
  • A feature-level comparison with AI Dungeon, Dramatron and NovelAI puts the system ahead on deployment flexibility, cost, multimodal output and openness, while AI Dungeon leads on user control and Dramatron on coherence.
Radar chart comparing the proposed system with AI Dungeon, Dramatron and NovelAI on deployment flexibility, coherence, user control, open source, multimodal output, accessibility and cost efficiency.
ResultsRadar comparison of the proposed system against AI Dungeon, Dramatron and NovelAI across seven dimensions.
Heatmap of normalised energy per frequency band for the ambient music preset of each genre, from fantasy and sci-fi to horror and comedy.
ResultsHeatmap of normalised energy per frequency band for each genre’s ambient music preset.

The music presets were analysed too. Horror and thriller put their energy in the low bands, while comedy sits in the mid and upper bands, so each genre sounds distinct.

IEEE-format two-column results page of the interactive storytelling paper, with bar charts, box plots and stacked timing bars for latency, token usage, narrative quality, user satisfaction and consistency checking.
IEEE-format paperIEEE-format two-column paper, results page: latency by LLM provider, token usage by genre, end-to-end timing, user satisfaction and consistency-check performance.

Shown with student, guide and institute details removed.

What did the student receive?

Files handed over for this project
DeliverableWhat it contains
Web app and source codeFastAPI backend with the seven pipeline modules, LLM provider adapters, SQLite storage, and the front end with D3 visualisations
IEEE-format paperTwo-column paper with the architecture, method, evaluation figures and a comparison with existing tools
Single-column research paperA longer version with fuller method and implementation detail
M.Tech dissertationLaTeX dissertation: literature survey, problem and objectives, planning, design, implementation, testing, results and future scope
Result figuresPlots and diagrams for latency, narrative quality, satisfaction, consistency checks and the music analysis
Presentation slidesSlide decks for project reviews and the final presentation

Need only the write-up for your own project? See dissertation, report and PPT support.

How could you adapt this project to your own topic?

The Q&A-to-prompt pipeline carries over to many M.Tech LLM projects in generative AI and NLP. These are starting points to discuss with your guide.

Topic ideas, not delivered projects

The ideas below are suggestions. Our delivered work is in the case studies.

  • Topic ideaSemantic consistency checkingReplace keyword rules with a natural-language-inference or embedding model and compare how well each catches tone shifts.
  • Topic ideaLong-story memory with retrievalStore past chapters in a vector index and retrieve the facts that matter, instead of a fixed window of recent turns.
  • Topic ideaGraded readers for language learningAdapt vocabulary and sentence length to a learner’s level, in English or an Indian language.
  • Topic ideaLLM-as-judge evaluationScore coherence and creativity automatically and measure agreement with human ratings.

For more options at this level, see M.Tech projects; for a smaller build, see final year projects for CSE.

Frequently asked questions

Can I get a similar interactive storytelling project?

Yes. We plan it with you in the free consultation around your own topic, your guide’s requirements and your deadline, so it is your project rather than a copy of this one. The written quote lists each deliverable, such as code, paper, dissertation and viva preparation.

Do I need a paid API key or a GPU?

No. The app can run a local model through Ollama on a laptop, or use the free tiers of Groq or Hugging Face; OpenAI is optional. Local models answer more slowly, which the project measured and reported.

Which datasets does it use?

No training dataset is needed, because pretrained LLMs write the story through prompts. The evaluation data came from stories generated with the system and a user questionnaire. If your guide asks for a dataset, a fine-tuning or benchmark step on a public story dataset can be added.

What will I need to explain in the viva?

How answers become a structured story context, how prompts change with genre and story phase, how the five-phase arc controls pacing, how the consistency checks work and where they fall short, why the LLM layer is provider-agnostic, and how the user study was run. A walkthrough session covers each point until you can explain it in your own words.

Is this suitable for a B.Tech final-year project?

It was delivered as an M.Tech project. A smaller version, with the question flow, one LLM provider and story export, can be sized for a final-year B.Tech project; the scope is agreed in the free consultation.

Delivered work

Related case studies

More M.Tech projects we delivered, shown with names and institute details removed.

Planning an NLP or GenAI project? Share your idea first.

Share your level, topic and deadline. You get a written plan and a fixed quote, and the consultation is free.

B.Tech · M.Tech · PhD · Projects · Papers · Thesis · Reports

WhatsApp Free consultation