Introduction

Imagine, droids came to the 21st century with the knowledge of the future but only had current technology to rewrite their Star Wars story.

In this article, we will see how a droid (machine learning model) generates its Star Wars story using knowledge of the future (Star Wars books).

Image for post

The Architecture of Model

The model takes the input sequence of words. We use LSTM to understand the context in a sentence. Since simple RNN would have vanishing gradient problem, so for the text generation I am using LSTM.

The output of the model is word scores for most likely next word. The following code shows the model architecture using PyTorch.

Story Generation

The story generation is done by taking a single word and text length as inputs. The word is passed to the model to get the next most likely word and we continue this process until the text length is reached. Top K sampling is used to introduce some randomness in choosing the next most likely word.

#machine-learning #fiction #technology #artificial-intelligence #star-wars #deep learning

A Star Wars Story by Sentient Droid
1.05 GEEK