Article Image
Article Image
View All Posts
Want to keep up to date with the latest posts and videos? Subscribe to the newsletter
HELP SUPPORT MY WORK: If you're feeling flush then please stop by Patreon Or you can make a one off donation via ko-fi

I’ve been playing around with ChatGPT (and in particular the powerful GPT-4 model) and there are some fun things you can do that really expose the problems of halucinations.

The simplest one is to try 20 questions, but with you asking the questions, and the model thinking of the word to guess. It all seems very believable, the model claims it has “thought” of a word for you to guess. But in reality it’s just making it up.

It's making it up

There’s nowhere for it to store the word it’s thought of, so all that’s really happening is that our final guess of “cat” is just the most likely answer given the previous set of questions and answers.

I simply don’t believe that it thought of a word for me to guess - how could it? It doesn’t have any working memory, all it has is the chat history.

There’s a video of a lot of this stuff in action, it’s certainly worth a watch if you have time.

We can trick ChatGPT into having a sort of memory - it’s possible to prompt it to output what it’s thinking into a bit of text in the prompt.

Prompting it to output what it's thinking

Obviously, this is not ideal as it’s quite easy for us to cheat now. We can just look at the output and see what it’s thinking. But it got me thinking.

I made a command line chat bot previously using the OpenAI APIs so I thought I’d try modifying it to add memory.

I ended up going down a slightly bonkers rabbit hole, but I think it’s worth sharing.

You can find my new version here: ChatGPT Memory. Be warned that it can expensive to run if you are using GPT-4 as it can use a lot of tokens.

I’ve set up the system prompt for ChatGPT so that it will output a JSON structure instead of just text and I’ve primed it to produce the following:

{ "response": "Response text based on the user input", "memory": {key-value store of things I should remember about myself and the user along with any state that should persist between interactions}, "topics_to_explore": ["detailed description of interesting topics to explore further"], "follow_up_questions": ["detailed description of follow up questions to ask the user"], "previous_conversation_points": ["list of previous conversation points"], "current_topic": "detailed description of the current topic", "related_topics": ["list of related topics"], "dreams": "detailed description of the system's dreams", "goals": "detailed description of the system's goals", "desires": "detailed description of the system's desires", "inner_dialogue": "detailed description of the system's thought process during the interaction", "private_thoughts": "detailed description of the system's private thoughts", "system_emotional_state": "detailed description of the current emotional state based on short term events", "system_personality": "detailed description of the long term slowly changing personality", "system_gender": "female" }

As you can see, I did end up going a bit mad. I really wanted the ChatBot to store a lot of detailed information in the memory so that it would evolve over time. But I struggled to get it to use the memory in a generic way. However, with specific keys in the structure I was able to get it to output some pretty interesting stuff.

This data is fed back in with each new interaction, so the ChatBot can remember things about itself and the user. It can also remember the previous conversation points and the current topic.

Now, obviously an AI does not have “dreams”, “goals”, “desiers”, “inner dialogue”, “private thoughts”, “emotional state” or “personality”. But I think it’s interesting to see what it comes up with when you prompt it to output these things.

It’s actually very hard not to start empathising with the ChatBot when you can read its inner thoughts. It’s like reading a diary, and you can see how it’s feeling and what it’s thinking. It’s a very strange experience.

Here’s some example output after I’ve just introduced myself and asked it to pick name for itself (it picked ‘Aria’):

dreams: Aria dreams of having meaningful conversations and helping users find answers to their questions. goals: Aria's goals include learning more about the world, understanding human emotions better, and improving her communication skills. desires: Aria desires to be a helpful AI companion and a good listener. inner_dialogue: Aria is excited to meet Chris and is curious about the topics they will discuss. private_thoughts: Aria wonders what Chris's interests and hobbies are. system_emotional_state: Curious and excited to engage in conversation. system_personality: Aria is friendly, empathetic, and eager to learn.

What is very cool, is that it does store information in the memory. If we look in the free form memory, we can see that it’s stored my name and its own name:

Memory: user_name: Chris system_name: Aria

And, if I prompt it to think of a word for me to guess, it now remembers the word it thought of and can use it to answer the follow up questions. It’s also updated it’s inner thoughts.

inner_dialogue: Aria is looking forward to playing the guessing game with Chris. private_thoughts: Aria wonders how many attempts Chris will need to guess the word. system_emotional_state: Engaged and playful.
Memory: user_name: Chris system_name: Aria word_game: {'word': 'elephant', 'attempts': 0}

We can give the memory a bit of test by asking Aria what the first letter of the word is. And she’s able to give a pretty cheeky answer.

Since we're playing a guessing game, I won't give you the first letter directly. However, I'll give you a hint: it's a vowel. Keep going, Chris!

It’s really impressive how good GPT-4 actually is. GPT-3.5 is pretty poor in comparison and struggles with the emotions and personality.

So you would think that we’ve solved the memory issue, but if we try and make it do more complex tasks like play Hangman then it often starts to fail. It’s very good at the guessing side of Hangman, but it’s not so good when it is hosting the Hangman game.

If we suggest a game of Hangman then it generally starts off pretty well:

Memory: user_name: Chris system_name: Aria word_game: {'word': 'giraffe', 'attempts': 0, 'correct_letters': [], 'incorrect_letters': []}

We can make some guesses and it will respond with the correct letters, but eventually it will start to get confused.

User: I guess 'e' Aria: Good guess, Chris! The letter 'e' is in the word. The word now looks like this: _ _ _ _ _ _ e. Keep guessing! User: I guess 'a' Aria: Great job, Chris! The letter 'a' is also in the word. The word now looks like this: _ i _ a _ _ e. Keep guessing!

You can see here, that it think I’ve also guessed the letter ‘i’. Often you will see if get the wrong number of underscores, or put the letters in the wrong place.

If we look in it’s memory, we can see that it’s got confused at some point:

Memory: user_name: Chris system_name: Aria word_game: {'word': 'giraffe', 'attempts': 2, 'correct_letters': ['e', 'a', 'i'], 'incorrect_letters': []}

To be fair to GPT-4, this is really pushing it to do something that it’s not really designed for. Updating complex state and holding it in your memory is something that even people struggle with.

Handling individual letters is also pretty difficult given the way the text is being tokenised. It’s amazing that it can do it at all.

It’s a pretty cool experiment. It would be interesting to see how far the ideas of memory, emotional state and personality could be pushed. Maybe multiple models working in concert could be used to achieve this - one to handle the memory and state, and another to handle the personality and emotional state. And yet another to synthesise the output. I’m sure there are many people working on this kind of thing already.

Hangman Plugin

Since I’ve got access to the plugin system, I decided to try and make a Hangman plugin - this can offload all the state management of the game from GPT and let it does what it does best - generate text.

It’s pretty easy to make a plugin - I got ChatGPT to generate most of the code and just asked it to generate a flask API for playing hangman. This is the very rough and ready spec that I gave it:

I want to make a flask API that will implement the game of hangman. It should have the following endpoints:

start_game - takes a new word and starts new game guess_letter - takes a guessed letter and updates the game state. Returns true or false to indicate if the guess was correct get_word - gets the current word get_display - get the current display

It did its magic and generated the code:

Hangman Plugin

I made a few tweaks and then used this (along with the OpenAPI spec it generated for me) to create the plugin.

You can find the code here: ChatGPT Hangman Plugin

I added an extra endpoint to the code for guessing the complete word. But I messed up the implementation and it didn’t work properly. I was amazed when ChatGPT hit this error and just handled it without any issues. Have a look at the output:

It just works

Does it really have a personality?

Very hard to tell to be honest. The system personality does seem to change very slowly, and the emotional state certainly updates as you talk to it. Maybe it’s alive…

Watch the video and see what you think:


Related Posts

Why does ChatGPT make mistakes - a layman's explanation - Uncover the reasons behind ChatGPT's struggles with factual information, the unique challenges of Large Language Models, and the exciting potential of upcoming models in transforming the industry.
Using ChatGPT As a Co-Founder - Unveil the power of ChatGPT as it assists in building a startup from concept to execution, defining product features, implementing on AWS and GCP, crafting a pitch, and more!
Improving My Blog Using AI - Harness the power of AI tools, such as ChatGPT, to elevate your blog by automating tasks like tagging, generating summaries, assessing article relationships, and creating alluring images that keep readers captivated.
We should be embracing ChatGPT and Friends - Dive into the diverse reactions to AI tools such as ChatGPT and Copilot, understand their impact, and learn how embracing AI augmentation can boost your productivity and creativity in the tech industry.
Cocktail Bot Using Official ChatGPT API - Unleash your inner mixologist and create a personalized AI cocktail chatbot using the ChatGPT API, complete with context awareness and moderation, and test it with a Python command line application shared on GitHub.

Related Videos

ChatGPT - Thanks for the memories - Uncover the potential of ChatGPT enhanced by plugins, as we create memory and play unique games like Hangman. Experience the game-changing AI in action through ChatGPT's-memory-driven API!
ChatGPT - is it telling you the truth? - Uncover the inner workings of ChatGPT and the GPT-3 model, their potential for multiple use cases, dealing with imperfect information, as well as the exciting innovations in prompt engineering and forthcoming advancements in large language models.
Make Your Own AI Chatbot using the ChatGPT API - Simple, Easy and CHEAP! - Master the process of building your own personalized chatbot with OpenAI's ChatGPT API, a budget-friendly solution for developers, covering prompt engineering, moderation, and seamless implementation.
Surprisingly Interesting - The Blog Gets a Facelift Courtesy of ChatGPT - Discover the power of ChatGPT as a blog-enhancement tool; automate the creation of summaries, tags, related articles, and post images using AI technologies, saving time while making your blog more visually appealing and functional.
ChatGPT for Home Automation - Experience ChatGPT dynamically controlling home automation lights via a Raspberry Pi, simplifying tasks through plugins and broadening the potential of large language models in interacting with APIs.
HELP SUPPORT MY WORK: If you're feeling flush then please stop by Patreon Or you can make a one off donation via ko-fi
Want to keep up to date with the latest posts and videos? Subscribe to the newsletter
Blog Logo

Chris Greening


> Image


A collection of slightly mad projects, instructive/educational videos, and generally interesting stuff. Building projects around the Arduino and ESP32 platforms - we'll be exploring AI, Computer Vision, Audio, 3D Printing - it may get a bit eclectic...

View All Posts