Today in class you will train GPT-3 to perform dialogue for non-player characters in games. We will use a different part of Facebook’s LIGHT dataset, which we previously used to generate descriptions for items and locations in our text adventure games.
Characters in the LIGHT dataset have a description and a persona, which is a first person description of who they are and what their motivations might be. Here are some examples of characters’ names and their personas in LIGHT.
Here is an example conversation from the LIGHT dataset. It’s a dialogue between two characters in a specific setting. Each character takes a turn in the conversation, which can consist of a line of dialogue, or an action (which I’ve maked as “stage direction” as if this were a play), or they can make a gesture (called an emote in the LIGHT data).
Setting:
- Watchtower - The tower is the largest section of the castle. It contains an observatory for nighttime scouting, but is also used by the wise men to study the stars. Armed guardsmen are always to be found keeping watch.
Characters:
- Court wizard - I am an advisor of anything magical. I sell spells to those who need them. I am wealthy and hold an important place in political life
- Soldier - I came from the fertile valley when I was conscripted. The king needed strong farmer’s sons to fight in the war. I am very unhappy here in the cold, damp, rainy north. I miss my friends and my dog. I hope to go back to my father’s farm when the war ends.
Conversation:
Court wizard: “A quiet night this evening…”
Soldier: “Yes it is”
Court wizard: “Have any else come up this eve? i had hoped for a quiet night to examine the stars”
Court wizard: Gestures - Ponder
Soldier: “Yes, a few came through, but it is a cold night for me, i am used to warmer weather”
Soldier: Gestures - Nod
Court wizard: “Well, you are but a common soldier. no doubt you are used to such a lot. thankfully i have my spells to keep me warm.”
Court wizard: Gestures - Sigh
Soldier: “I am a soldier doing my job”
Soldier: Gestures - Grin
Court wizard: “Yes… well… very well then. see that you do! no slacking off while your betters are about.”
Soldier: “No sir”
Court wizard: “When, for example, was this horn last tested? it looks dented. how can we be sure it will work?”
Soldier: “A year ago, test it out or cause a need to use it”
Court wizard: “Mayhap i will speak to the king about such lackness. or perhaps i can sell him a spell that will serve just as well.”
Court wizard: Gestures - Frown
Soldier: “Good idea, i agree, go do that”
Soldier: Stage Direction - Hug court wizard
Court wizard: “Get off of me, you fool! who gave you permission to touch me!”
Court wizard: Stage Direction - Hit soldier
Soldier: “To the jail with you”
Soldier: Stage Direction - Hit court wizard
We will use the OpenAI API to perform dialogue in a similar style to the LIGHT dialogue. We will try two approaches:
You can start out by experimenting with few-shot learning on the OpenAI playground. All you need to do is copy and paste two or three of the LIGHT dialogues into the playground. Then add the appropriate infomation for the conversation that you want to generate. Like the settings and the characters. If you use all that as the prompt, then GPT-3 should generate something like this:
If you want to change its behavior so that it it only generates one line at a time, then you can enter the newline character into the “Stop sequences” field on the right. (To do this, click in the textbox, press Return, and then press Tab).
If you set it up to generate one line of dialogue at a time, then you can have it play one of the characters, and you can play the other character by typing in your response. This should be a reasonable starting point for dialogue in an interactice fiction game.
File > Save a copy in Drive
.action_castle.txt
action_castle.txt
file to Gradescope.