What Is ChatGPT Doing and Why Does It Work?

A book by Stephen Wolfram. Published March 10, 2023. Wolfram Media. Paperback (103 pages) or ebook at Amazon at amazon.com/dp/B0BY59PT5Z. Free at wolfr.am/SW-ChatGPT

A short summary and comments by Andreas Ramos. Comments and edits by Pamela Gauci, Alok Gupta, and others. Updated May 31.

Let me know your comments and ideas. -- andreas.


Stephen Wolfram is a leading mathematician and AI researcher. He built WolframAlpha.com, Mathematica, and other tools. See more about him on Wikipedia.

This review has page notes to the print book. For example, (p. 25.4) means page 25, about 40% down the page.

How ChatGPT Works

ChatGPT guesses the next word in a text, such as "The cat sleeps on the ______." Possible words to complete the sentence include "sofa," "bed," "rug," and others. To determine the likelihood of each word appearing in the sentence, ChatGPT reviewed 40,000 English words from a variety of sources, including five million books, Wikipedia, and selected websites and assigned probability values to each word and ranked them by frequency (e.g., "sofa = 4.5%", "bed = 3.2%", "rug = 2.7%", etc.) for that particular sentence.

Developers found that if ChatGPT picks the highest-probability word (such as "sofa" at 4.5%), the resulting text can be dull and flat. However, by randomly selecting lower probability words, the generated text becomes more interesting.

ChatGPT’s success is due to the attention mechanism, which helps the model look beyond word order and focus on context.

ChatGPT performs 175 billion calculations and uses 400 layers (essentially, rules) to randomly select each word in a sentence, such as, "The cat sleeps on the soft bed in a beam of early morning sunlight." This means the same prompt will produce different versions each time. You can see this for yourself. Enter a long prompt several times and compare the results.

Patterns in the Randomness

ChatGPT can generate essays, stories, speeches, movie scripts, book outlines, and more (p. 25.2). This was not programmed in ChatGPT; instead, it identified patterns in text data on its own and created those texts.

How did the AI discover patterns? Let’s say you want it to find a pattern for cats. It seems you can start by giving a few clear examples to the AI (such as fifty clear photos of cats), and it would notice a pattern, such as, “if pointy ears and whiskers, then it’s a cat.” Developers discovered, however, it works better to upload tens of thousands of cat photos (including messy examples, such as cats dressed as dogs and a few rabbits) and let the AI create its own patterns of “general catness” (p. 25.4).

Researchers found an AI can differentiate between male and female in the iris of the human eye, even though experts had no idea there was a difference and couldn’t see any difference. What the AI finds to tell the difference is unknown.

This means ChatGPT can solve complex problems better than simple problems because the more examples it has, the better it can find patterns (p. 28.8).

Furthermore, the same process works well for different tasks (p. 30.4). ChatGPT can also produce images. Nobody expected any of these results. ChatGPT may have additional, yet undiscovered, capabilities.

There is no concrete theory or set of rules governing ChatGPT's development. Developers experiment with various ideas, and while some succeed and others fail, the reasons for these outcomes remain unclear. Successful approaches are kept, and further experimentation continues (p. 22.2, 48.9, 49.1, 49.9, 51.5).

This also means we can’t understand ChatGPT. To explain how it works, a calculation with six parameters can be described (p. 18.2), but this becomes overwhelming when there are 175 billion parameters.

Wolfram writes, “And, yes, (GPT) is basically an art. Sometimes—especially in retrospect—one can see at least a glimmer of a “scientific explanation” for something that’s being done. But mostly things have been discovered by trial and error, adding ideas and tricks that have progressively built a significant lore about how to work with neural nets.” (p. 30.1).

Training the AI

A team of 2,000 people at OpenAI train ChatGPT's output, labeling it as good or bad (p. 56.4). This must be done by humans because there is no existing theory or method to determine whether a text is meaningful or not (p. 63.2). For instance, the sentence "Elephants travel to the moon" is grammatically accurate but illogical.

OpenAI reviews what people type into ChatGPT and the results (about 10 million entries per day), as well as tens of thousands of daily messages in Twitter and Reddit.

Increasing the size of an AI doesn't mean it will work better. ChatGPT has 175 billion parameters, and some say a trillion parameters would be better. But it’s not a question of parameters. It’s the training by humans that improves an AI's ability to produce useful results.

For comparison, the Google Brain AI uses 200 criteria (layers) and 70 billion parameters to sort and rank web pages and ads, among other things. Google has been using this since 2019.

Computational Language and ChatGPT

In his book (pages 71-74), Stephen Wolfram discusses the potential for ChatGPT to develop a "computational language" capable of generating meaningful text (and avoiding mistakes).

This is like his idea of computational science, where a few fundamental mathematical formulas can calculate the behavior of things in physics, chemistry, biology, and other fields. For example, a rock falls according to the formula F = G(m1m2)/R2 every time, everywhere.

Computational science works because facts in the physical world can be measured down to sixteen decimal places and the behavior of things such as gravity can be represented with mathematical formulas.

Stephen Wolfram suggests his computational science engine WolframAlpha can be the “fact verification” tool within ChatGPT to ensure accurate information about the physical world, mathematics, and related subjects (pages 79-98).

Summary of Wolfram’s Book

There are several things going on in this short book.

  • Stephen Wolfram gives a clear overview of how ChatGPT works.
  • He adds insights about the nature of ChatGPT. ChatGPT was not programmed, many of its behaviors were not expected, and nobody can explain why a particular result appears.
  • He strongly argues his software WolframAlpha should be part of ChatGPT. It's already a plugin. It wouldn’t surprise me if he is trying to sell or license WolframAlpha to Microsoft or Google.

Additional Notes: Upcoming in ChatGPT

OpenAI has said there will be versions of ChatGPT. These could include:

  • Domains: ChatGPTs for topics such as science, history, literature, home, and so on.
  • Countries: ChatGPTs for the US, France, Japan, and so on.
  • Business: Accounts for companies with accounts for staff. Data could be protected (not shared with OpenAI).
  • Personalized: Your account could be personalized to your interests, location, use, tone, and so on, along with your settings, like how Amazon is personalized for each customer.

BTW, you can change your ChatGPT settings so your data isn’t shared with OpenAI for training. People in government, medicine, law, finance, and similar should consider this. Go to Settings | Data Controls | Chat History and turn off to not share data.

Further Reading