DEV Community

Luke Floden
Luke Floden

Posted on

Using GPT-2 to Create Bedtime Stories

My Final Project

Sleep Story Machine is my capstone project for my undergrad in CSE at UofL. Me and three other students implemented this as an independent project; rather than working with an external company (as is the norm). The goal of this project is to demonstrate the advancements in machine learning by providing easily accessible and novel bedtime stories to children.

Sleep Story Machine is accessible from its web interface (sleepstorymachine.xyz) or through Google Assistant. The later makes possible a scenario in which a Google Home device could lull the user to sleep with a simple voice command.

The story generation is handled by Open-AI's GPT-2 model and is fine-tuned on Grimm's fairy-tales.

Demo Link

https://sleepstorymachine.xyz:5000

Link to Code

Github repo

How I built it

Overview

  • User input
    • On the web interface this is a simple text box. This is fed directly into the model
    • The Google assistant asks for a topic from the user. This topic is then inserted into one of a few static templates in order to improve story generation.
    • ex. Topic given: "a puppy" -> "Once upon a time a 'puppy' set out on an adventure..."
  • Text generation
    • The input is passed to a worker that feeds it to the running GPT-2 model. After a short amount of time the model then returns new text.
    • If returning to the assistant the generated text is sent directly back.
    • If returning to the web interface, the text is wrapped in html so that it can be loaded into the webpage.
  • Output
    • The assistant front end reads the story to the user and then asks for another topic.
    • The web interface prints multiple results and also provides highlighted text based on the logits produced by GPT-2

Stack

Issues

The major issue was the ability to fine-tune the model:

  • Amount of data online that could legally be used
  • Difficulty, this was our first deep learning NLP project.
  • Compute resources

Additional Thoughts

I would like to revisit this project with new skills under my belt and improve it. Maybe use higher level tools like huggingface transformers.

Top comments (5)

Collapse
 
amananandrai profile image
amananandrai

Awesome project but could not open the link. I like the idea of the project but would love to see it in working mode

Collapse
 
bionboy profile image
Luke Floden

I ran out of Google Cloud Platform free credits so I took it down temporarily. Its on my list to get running again!

Collapse
 
amananandrai profile image
amananandrai

Ok will love to see the project running once more.

Collapse
 
roblox22r profile image
Roblox studio

where is it

Collapse
 
bionboy profile image
Luke Floden

I ran out of credits on the hosting platform so I took it down. You can follow the instructions in the GitHub repo and run it yourself if you would like!