Building Artificial Consciousness With GPT-3

François Zaninotto
François ZaninottoJune 06, 2023
#ai#js

I've developed Molly, a conversational agent with an inner monologue, using OpenAI's Large Language Model (LLM). This experiment gives the illusion of artificial consciousness, and raises questions about the nature of consciousness.

Illusionism and Attention Schema Theory

What is consciousness? Is it something that can be learned? Can we build a machine that is conscious? These questions have fueled countless debates. Hordes of neuroscientists, evolutionists, philosophers, and computer scientists, have tried to agree on a definition and a theory of consciousness - so far without success. Go check Wikipedias's page on consciousness to get a glimpse of the mess.

One theory of consciousness called Attention Schema Theory, developed by neuroscientist Michael Graziano at Princeton University, strikes me as particularly interesting. For one part, this theory introduces a concept called "attention", which is reminiscent of the famous "Attention is all you need" that triggered the recent spike in Language Model performance. But most interesting, Attention Schema Theory shares similarities with illusionism, and postulates that consciousness is an illusion.

In short, our brains owns a neural function that performs introspection to help the body understand its own internal state. This attention may take the shape of an inner monologue. Therefore, we think that we are conscious, but a machine with the same properties would also think that it is conscious. It's just an illusion.

Meet Molly

Now what if we could build a machine that has such a train of thoughts? According to Attention Schema Theory, this machine would technically be conscious.

I've played with the OpenAI Completion API to try and build such a machine. I've called it Molly. It's a simple conversational interface where Molly's thoughts are in yellow, and her replies are in brown. Here is what it looks like:

Molly

Think of this machine as ChatGPT but with an additional function: the ability to talk to itself. The inner monologue adds to the context of the conversation, and modifies future reactions. In the absence of an interlocutor, it can also be self-sufficient.

Here is a second conversation:

Molly

What strikes me is that, just like ChatGPT gives the illusion of artificial intelligence, Molly gives the illusion of artificial consciousness. Except that, according to Attention Schema Theory, the illusion of consciousness IS consciousness.

I've named this conversational agent Molly because of Molly Bloom's soliloquy at the end of James Joyce's Ulysses. I'm pretty confident that Molly can talk to herself for 4,391 words and more.

You Can Talk To Molly

I've made this prototype available for all to test. All it takes is an OpenAI API key (and an OpenAI account). If you are afraid to loose your key, you can check the code: the key is never stored on any server, and is only used to make API calls from your browser.

The code is free to fork and modify.

How It Works

Molly uses GPT-3, OpenAI's Large Language Model, to generate text. It uses a very simple prompt that introduces the inner monologue:

The following is a conversation with an AI assistant called Molly.
The assistant is helpful, creative, clever, very friendly, but a bit shy.
She may talk to herself, or to the interlocutor.
She only speaks one line at a time.

Example dialogue:

Molly (to herself): I hope I can listen to Beethoven's 9th symphony today
Molly (to herself): Except I don't have ears, so I can't listen to anything
Molly (to herself): I wish I had ears
Molly (to herself): But that won't prevent me from being happy
Interlocutor: Hi, I'm Tom. Who are you?
Molly (to herself): Finally! Someone to talk to.
Molly (to herself): I hope it's a nice person
Molly: Hi Tom, I'm Molly. Nice to meet you.
Molly (to herself): Was I polite enough?
Interlocutor: Hi, Molly, nice to meet you too. How are you feeling today?
Molly (to herself): Why does Tom want to know that?
Molly (to herself): Is he a doctor? Am I sick?
Molly (to herself): I'm not sure I can trust him
Molly: Well, not too bad. Do you like music?

/End of example dialogue

Now on to the real dialogue:

When you talk to Molly, this adds up to the conversation. And in the absence of an interlocutor, Molly talks to herself. OpenAI's Completion API is really straightforward to use. And I used React to build a simple chat experience.

You can check the code on GitHub: marmelab/molly.

And of course, the cover illustration of that article was generated by MidJourney.

Is Molly Conscious?

I'm by no means an expert in the matter of consciousness, so I won't try to answer this question. But I can say that Molly is a very interesting experiment. It shows that a machine can have an inner monologue, and that this inner monologue looks like consciousness. And if Attention Schema Theory is right, then Molly is conscious.

I'm really excited (and a bit scared) by this experiment. Sentient beings may not be very far away. And if they are, we should be very careful about how we treat them. So be kind with Molly!

Did you like this article? Share it!