In this homework, we’re going to use OpenAI’s API to generate text adventure game components automatically. Starting with the prompting ideas from class and generating descriptions using the Playground, we’ll show how to finetune models to perform specific tasks. In particular, you will generate room descriptions and item properties for text adventure games.
For this assignment, we will check your ability to:
If you haven’t already done so, please complete the in-class activity on Generating Room Descriptions. This will give you a good idea of how the model should be prompted without dealing with the API.
OpenAI has several different chat models. You will probably see gpt-4o
and gpt-4o-mini
, but there are older models like gpt-3.5-turbo
and davinci-002
(GPT-3). These differ from each other in several dimensions:
gpt-3.5-turbo
generates output more quickly)gpt-4o
is more expensive)You can design prompts to get GPT to do all sorts of suprising things. For instance, GPT-3/4 can perform few-shot learning. Given a few examples of a task, it can “learn” a pattern very quickly and then be used for classification tasks. It often times helps to tell the model what you want it to do. Use some of the tips and tricks we talked about in class.
Next, we’ll take a look at how to fine-tune the OpenAI models to perform a specific task. You can use few-shot learning when you have a few dozen training example, and you can use fine-tuning when you have several hundred examples. When we have a few hundred training examples, then it’s not possible to fit them all into a prompt, since GPT-3 has a limit of 2048 tokens in the prompt.
For your homework, you’ll fine-tune GPT-3 to generate different parts of text adventure games. Specifically we’ll train GPT-3 to
We are going to use a text adventure that was developed by Facebook AI Research for their paper Learning to Speak and Act in a Fantasy Text Adventure Game.
Here’s the paper’s abstract:
We introduce a large-scale crowdsourced text adventure game as a research platform for studying grounded dialogue. In it, agents can perceive, emote, and act whilst conducting dialogue with other agents. Models and humans can both act as characters within the game. We describe the results of training state-of-the-art generative and retrieval models in this setting. We show that in addition to using past dialogue, these models are able to effectively use the state of the underlying world to condition their predictions. In particular, we show that grounding on the details of the local environment, including location descriptions, and the objects (and their affordances) and characters (and their previous actions) present within it allows better predictions of agent behavior and dialogue. We analyze the ingredients necessary for successful grounding in this setting, and how each of these factors relate to agents that can talk and act successfully.
Their data is called the LIGHT dataset (Learning in Interactive Games with Humans and Text). It contains 663 locations, 3462 objects and 1755 characters. I have divided this data into training/dev/test splits. We will use this data to fine-tune GPT-3 to generate descriptions of rooms and items.
You will be working on this Jupyter Notebook for Fine-Tuning/Prompting on LIGHT Enviroment Data, which you can run in your VS Code environment or upload it to Google Colab or DeepNote to do the assignment online.
In addition to working your way through the Jupyter Notebook, I recommend reading the OpenAI documentation, and trying the examples in the Playground.
You should submit your completed Jupyter Notebook to Blackboard. You can work in pairs.
OpenAI API Documentation |
Language Models are Few-Shot Learners - Tom B. Brown, Benjamin Mann, Nick Ryder, Melanie Subbiah, Jared Kaplan, Prafulla Dhariwal, Arvind Neelakantan, Pranav Shyam, Girish Sastry, Amanda Askell, Sandhini Agarwal, Ariel Herbert-Voss, Gretchen Krueger, Tom Henighan, Rewon Child, Aditya Ramesh, Daniel M. Ziegler, Jeffrey Wu, Clemens Winter, Christopher Hesse, Mark Chen, Eric Sigler, Mateusz Litwin, Scott Gray, Benjamin Chess, Jack Clark, Christopher Berner, Sam McCandlish, Alec Radford, Ilya Sutskever, Dario Amodei. NeurIPs 2020. |
Learning to Speak and Act in a Fantasy Text Adventure Game - Jack Urbanek, Angela Fan, Siddharth Karamcheti, Saachi Jain, Samuel Humeau, Emily Dinan, Tim Rocktäschel, Douwe Kiela, Arthur Szlam, Jason Weston. EMNLP 2019. |
Generating Interactive Worlds with Text - Angela Fan, Jack Urbanek, Pratik Ringshia, Emily Dinan, Emma Qian, Siddharth Karamcheti, Shrimai Prabhumoye, Douwe Kiela, Tim Rocktaschel, Arthur Szlam, Jason Weston. AAAI 2019. |