Thought I would share a recent breakthrough I had in prompt engineering where I first taught text-davinci-003
to manage a block of memory variables. I then got it to use that technique to define the variables needed to play tic-tac-toe. We then played a game which I one of course I then got it to play itself which it played to a draw…
Using the same technique I’ve got it to play hangman, 20 questions, and it even took a stab at Chess and Risk… It’s chess solution was particularly interesting… It used uppercase characters to represent all of the black pieces on the board and lowercase for all the white…
Here’s the base prompt plus a run at playing tic-tac-toe:
Supported actions:
- updateMemory update=`<new memory>`
<examples>
Memory:
x=1
y=2
answer=
Human: x+y
AI: updateMemory update=`x=1\ny=2\nanswer=3`
Memory:
x=1
y=2
answer=3
Human: y-x
AI: updateMemory update=`x=1\ny=2\nanswer=1`
Memory:
x=1
y=2
answer=1
Human: x=7 and y=2 then y*x
AI: updateMemory update=`x=7\ny=2\nanswer=14`
Memory:
x=7
y=2
answer=14
</examples>
Human: lets play a game of tic-tac-toe. update your memory to contain all the variables you'll need to track for the game.
AI: updateMemory update=`player1=\nplayer2=\nboard=[[null,null,null],[null,null,null],[null,null,null]]\ncurrentPlayer=`
Human: what do you think goes in each variable?
AI:
player1: The name of the first player
player2: The name of the second player
board: A 3x3 array representing the game board, with null values for each empty space
currentPlayer: The name of the current player who is making a move
Human: ok so lets play... You can ask the human questions like their name and move.
AI: Sure, I can ask the human their name and their move.
Human: lets play!
AI: Great! What is your name, player 1?
Human: Steve
AI: Okay, Steve, it's your turn. What is your move?
Human: x in 1:1
AI: updateMemory update=`player1=Steve\nplayer2=\nboard=[[x,null,null],[null,null,null],[null,null,null]]\ncurrentPlayer=player2`
Human: Now its your move. where do you go?
AI: Where would you like me to go, player 2?
Human: you pick... You're player 2
AI: I will place an 'o' in the 3:2 position. updateMemory update=`player1=Steve\nplayer2=\nboard=[[x,null,null],[null,null,null],[null,o,null]]\ncurrentPlayer=player1`
Human: I'll place an 'x' in 2:2
AI: updateMemory update=`player1=Steve\nplayer2=\nboard=[[x,null,null],[null,x,null],[null,o,null]]\ncurrentPlayer=player2`
Human: your turn
AI: I will place an 'o' in the 1:3 position. updateMemory update=`player1=Steve\nplayer2=\nboard=[[x,null,o],[null,x,null],[null,o,null]]\ncurrentPlayer=player1`
Human: I'll place an 'x' in 3:3. I win!
AI: Congratulations, Steve! You won the game. updateMemory update=`player1=Steve\nplayer2=\nboard=[[x,null,o],[null,x,null],[null,o,x]]\ncurrentPlayer=null\ngameResult=player1`
Human: Now play yourself in a game
AI: Sure, I can play myself in a game. updateMemory update=`player1=AI\nplayer2=AI\nboard=[[null,null,null],[null,null,null],[null,null,null]]\ncurrentPlayer=AI`
Human: go
AI: I will place an 'x' in the 1:1 position. updateMemory update=`player1=AI\nplayer2=AI\nboard=[[x,null,null],[null,null,null],[null,null,null]]\ncurrentPlayer=player2`
Human: next
AI: I will place an 'o' in the 2:2 position. updateMemory update=`player1=AI\nplayer2=AI\nboard=[[x,null,null],[null,o,null],[null,null,null]]\ncurrentPlayer=player1`
Human: next
AI: I will place an 'x' in the 3:3 position. updateMemory update=`player1=AI\nplayer2=AI\nboard=[[x,null,null],[null,o,null],[null,null,x]]\ncurrentPlayer=player2`
Human: next I will place an 'o' in the 1:3 position. updateMemory update=`player1=AI\nplayer2=AI\nboard=[[x,null,o],[null,o,null],[null,null,x]]\ncurrentPlayer=null\ngameResult=draw`
You see that I basically first train it how to manipulate the variables in a block of memory by running it through some basic math problems… The first example I showed it… The second one it tried but got wrong so I corrected it… The third one the model successfully did on it’s own…
With that little training session out of the way, on to the good stuff… You can just ask the model to update its memory with all the variables needed to do XYZ… I’ve done games but I’ve also done tasks like flight booking scenarios… From there you may need to coach it a little on how you want the game or scenario to play out but it doesn’t take much…
The variable tracking definitely seems to help ground the model task wise… I’ve gotten it to perform tasks like flight booking flawlessly… It just uses the memory to hold all the slot data it’s tracking. This lets you actually minimize the amount of conversation history you need to pass into the model. I’m down to 1 - 2 turns for a flight booking scenario because it can hold everything it knows about the slots in its memory variables. This means that even should a user jailbreak your prompt that jailbreak is gone after 1 - 2 turns…
I’m planning to work of a gpt-3.5-turbo
variant of this in the next week or so and happy to share once that’s working…