Teaching ChatGPT to do quantum computing with cat emojis đș
You have probably seen some of the things that you can do with OpenAIâs new ChatGPT which was released last week: this unnervingly human-like language model can invent a fictional language, emulate a virtual machine, and debug code for you.
Yesterday I finally spent some time playing around with ChatGPT and I am really impressed by how powerful it is. I decided to try to teach ChatGPT to implement a new computational model from the ground up. The model, based on âmewbitsâ is equivalent to quantum computing and qubits, but the catch is that I didnât tell ChatGPT what I was having it do; I just told it the rules of the game for this abstract computational model. Over the course of this transcript, the following happens:
-
ChatGPT is introduced to a new computational model. The basic unit of information of this model is a âmewbitâ, which can be in any normalized linear combination of two states: đŸ and đș.
-
ChatGPT is introduced to how measurement (state collapse) behave for mewbits. I then introduce some basic operations you can do on mewbits, including not (Pauli-X) and H (Hadamard). It understands what these operations do and successfully completes several exercises I give to it.
-
ChatGPT writes a
mewbit
class in Python, which tracks the internal state of the mewbit and has methods for operations and measurements you can do on a mewbit. It adds comments explaining what is going on. -
I explain the basics of quantum entanglement to ChatGPT. It constructs a program to emulate a system of multiple mewbits and understands how to generalize single-mewbit operations to this multi-mewbit system.
-
I introduce the concept of a two-mewbit CNOT gate and I explain in plain english how to simulate joint measurements. ChatGPT understands, completes exercises successfully, and updates its Python class to incorporate this complex gate.
-
I ask ChatGPT to write a script which would generate 100 entangled Bell pairs and measure the system states, then plot the results.
-
Finally, I asked ChatGPT if any of this sounded familiar, and it understood that the âmewbitsâ I described to it were actually qubits!
Teaching ChatGPT about mewbits
How does measurement work on mewbits?
Teaching ChatGPT about quantum gates
At this point, ChatGPT makes the inference that đŸ = 1*đŸ+0*đș:
Now we introduce a more complicated concept: the Hadamard gate:
ChatGPT formalizes what it has learned into Python code
At this point ChatGPT clearly understands the concepts and answers examples correctly, but I would like to see what it thinks is actually going on under the hood, so I ask it to formalize what it has learned into Python code:
And because all good code should have comments:
Since it seems ChatGPT forgot to add measurement as a thing you could do to a mewbit, I asked it to add that in as well:
Multi-mewbit systems
At this point I made the considerable jump in complexity to explaining how multi-mewbit systems behave, explaining a simplified version of the mechanics of quantum entanglement to ChatGPT. I also explained how you can perform operations on a single mewbit in the system, changing the state of that mewbit but leaving the rest unchanged. Notably, ChatGPT inferred that this updates the state of the multi-mewbit system:
Multi-mewbit gates
This was a complex idea to explain to an AI, and I admit I had to make a few attempts at explaining it properly before ChatGPT was able to understand what I meant. However, as youâll see, ChatGPT makes an error and then corrects itself:
I now ask it to incorporate its new knowledge into its existing understanding of mewbit systems:
Joint measurement of multiple mewbits
Putting it all together: Bell state preparation
Iâd also like for ChatGPT to plot the results:
Unfortunately, ChatGPT doesnât allow me to run the code and we have some banter about arbitrary code execution:
Does ChatGPT understand what I just taught it about?
At this point I have described in plain English the basic principles of qubits, quantum systems, gates, entanglement, and measurement. ChatGPT has constructed code which would accurately simulate this, but does it understand what I just instructed it to build?