AI Dungeon 2: Creating Infinitely Generated Text Adventures with Deep Learning Language Models

Imagine an infinitely generated world that you could explore endlessly, continually finding entirely new content and adventures. What if you could also choose any action you can think of instead of being limited by the imagination of the developers who created the game?

This is the vision of AI Dungeon 2.

In the first AI Dungeon, we created and deployed a deep learning generated text adventure using OpenAI’s 124M parameter GPT-2 model. In the interest of computational cost, possible actions and their results were generated and given to the player to choose from.

In AI Dungeon 2 we do away with pregenerated actions and allow the user to enter any action. The model then continues generating the story resulting from that action. We also upgrade the size of our model to OpenAI’s largest 1.5B parameter model and fine-tune it on a collection of text adventures obtained from chooseyourstory.com.

Following the example of the Salesforce CTRL model we also modified the sampling of our model to add a penalty to already generated words to reduce the repetition issues that GPT-2 has and enable a lower temperature setting.

When playing AI Dungeon 2 the player can choose from several possible settings and characters. These choices generate a starting prompt and context sentence. The context sentence is always included as input to the model to help keep it grounded to the chosen setting while the starting prompt is the beginning of the story. For example if you choose to be a wizard named Zoltan in a fantasy world your adventure might begin like this.

You are Zoltan, a wizard living in the kingdom of Larion. You have a staff and a spellbook. You finish your long journey and finally arrive at the ruin you’ve been looking for. You look around and see [GENERATION BEGINS HERE] that it’s empty. “I guess I should go back to my home now”. You say. “Hm, well maybe you can find something there”. The voice says.
> see who the voice is

The voice comes from behind a large stone pillar. It’s very old and has many cracks in its facade. However, you know it’s not human because of the strange eyes staring out from its face. It looks like an old man with white hair and beard.
> ask the old man who he is

“Who are you?” You ask. “My name is Trelik, but you may call me whatever you wish”. He replies.

For each action you type the model is fed the context sentence as well as the past N action-result pairs in its memory to generate the result. We found N=8 to be a good amount of memory to feed the model.

The model at times shows remarkable understanding and writing quality like in this sample where the player tries to find love on a deserted island.

You head to the island and explore it. You find it completely deserted save for a single tree. You walk up to it and examine it closely. It seems to be made of wood, but its leaves seem to be green rather than normal leafy green.
> find love

You take a deep breath and stare intently at the tree. Your eyes meet with the tree’s. You immediately feel a strong sense of euphoria. You smile and touch the tree. Its bark feels warm to the touch. You sniff the tree and find that its scent is very pleasant.

Other times the model has difficulty keeping track of who is who, especially in dialogue.

You nod and explain that you need some new equipment. He tells you that he has plenty of gold in his treasury so you should just ask him for it.
> thank him for the equipment

“Thank you for the equipment, I will certainly look into this”. He says. With those words the king begins to leave. You thank him again before leaving.When you get outside you find yourself staring up at a massive stone wall.

Although AI Dungeon 2 has these limitations it is still a remarkable demonstration of language models’ ability to generate stories and a dramatic advancement in AI generated interactive fiction.

You can read more stories from AI Dungeon 2 and play the game yourself here.



Note: AI Dungeon 1 and 2 were created by Nick Walton with support from David Wingate, Max Robinson, and Alan Walton. It also couldn’t have been possible without OpenAI and their released GPT-2 models.