Making an AI to write Anime stories for me using Deep Learning.

So, I am a weeb

Making an AI to write Anime stories for me using Deep Learning.

So, I am a weeb

And I love anime. Like in just 24 episodes it can say so much and convey so much. So, the other day I was talking to my friend and due to something he said why don't you write a anime synopsis and my brain knowing that I have no talent of that front, thought let's make an AI to write anime stories for me.

And so basically let's get started.

First I needed a source of data and whats better than MAL(MY ANIME LIST) like its one of the biggest source of anime information in the whole internet basically.

But it has that side of anime too you know what side I am talking about.

So, let's remove that part.

Here is the code for it:

Lets create the dataset now:

The dataset needs to have the following specifications

  • Configuration Class
  • Join Synopsis
  • Token for Synopsis
  • Number of data batches
  • Create Vocal bury and Knowledge based on the synopsis
  • Create output tokens by shifting input tokes to the right.
  • Create a generator function which outputs the input and output sequences batch wise.
click here to see the dataset can’t add it to the article cuz its over 16600 rows!

Now for the Model

We will use something called LSTM(or long short term memory)Which are designed to capture a long term dependencies in a sequential format which the normal RNNs(Redcurrant Neural Network) can’t do and it does this by using many gates which look over the information that passes from one time step to another.

Now lets get to the training part

So, Basically this is a neural network and we will be using something called the cross entropy loss, this is the reason we are not passing the output through an explicit softmax layer as this loss function calculates that internally.

Lets see the code:

Now for the fun part lets generate Anime

The code for that goes as follows basically you have to provide the first 3 words of the text:

Now lets see some beautiful outputs( me exited😁)

Epoch’s are training
Its Done!!!
AI generated Anime synopsis:
'Bob the Architect in this series ; '' he finds how many friends about and falls along when demons must show it at any time with a mysterious young man she gets up , while dealing in his new lives ... as such he is transported a secret where these kids can seem for an entire ally.years before this . despite completing another life when you must find an old quest that was just an energetic stall.though the wrestling world to its serialization ... at st. 's past academy during class and finds the message 's lair from this unusual enemy for a life she was told out when he finds his friends ; one after him after something about more from being known until `` mcfat ... as there means you ... is the smartest , athletic school worker whose son s wife will now watch any new treasure for those ' `` i would survive together with something it wo expected his way true : his family for an uncanny kurta spirit who goes at the sky by any eccentric bread at school city usually called texhnolyze.
…'

Look at this beautiful synopsis a typical anime 😜

The GPT2 Method

This is good but as you might have noticed it doesn't have that good grammer. So let's see another method called the GPT2 (or the hugging face method ).

They have an awesome model check it out here.

The Code Using GPT2 Method:

This too 100 minutes to train and execute🥲
“Manas the Chad”
Adityavijayraj the Architect
Eeman and Vijus drug business name Pliz Palace

Here are some outputs:

AI Generated Synopsis:

 Manas the chad of the Earth is back in action, and this time he has the power to turn the tides of war in the form of a giant robot known as the Dragon. The Dragon is said to be able to save the world from the evils of mankind, but the truth behind its existence is shrouded in mystery.
AI Generated Synopsis: Adityavijayraj the Architect is a young man with a passion for architecture. In his spare time, he spends his time making friends and exploring the world around him.
AI Generated Synopsis: Eeman and Vijus drug business name Pliz Palace is one of the most well-known drug brands in the world. However, this is no ordinary drug company. In fact, it is a conglomerate of drug companies, each with their own brand of medicine. This is the story of a young man who has just started his life as a pharmacist.

Such great plots I would like real anime of these😜

As you can see it has much refined grammar and makes meaningful sentences. Hehe make yours and have fun 😁

If you liked it a follow on medium is appreciated , Here try the code for yourself 😁:

The GPT2 way (Better Generation)

You can find the Dataset here:

If you want more stuff check out my github:

For my day to day AI updates follow me on twitter:

Thanks for reading, See ya guys next week 👋🏼.