How does ChatGPT work? Simply explained

ChatGPT is not an encyclopedia and not a search engine. It writes text by predicting, again and again, which word should come next. That sounds simple. It also explains why ChatGPT writes so well and can still be wrong.

Last checked:

A language model predicts the next word

ChatGPT is a chatbot: you type a message, and an AI in the background writes the reply. That AI is a so-called language model. It has learned from huge amounts of text which word is likely to come next.

Experts talk about a large language model (LLM). The language model behind ChatGPT comes from OpenAI and is called GPT. Models like this are trained on vast amounts of text. In the first phase, called pretraining, they learn one thing: given the text so far, predict the next word (Anthropic glossary, Google). It works much like the word suggestions on your phone, only with far more text behind it (Hugging Face).

Text is cut into tokens

A model does not read single letters. It splits text into small parts called tokens. A short, common word is often one token. A longer word is split into several. As a rule of thumb, OpenAI gives one token as about four characters, or three quarters of an English word.

This is why chatbots can stumble on simple letter tasks, such as counting the letters in a word. Researchers trace this to tokenization: the model never sees the letters one by one.

The answer grows word by word

The model does not write a whole answer in one go. It adds a word, then the next. What is already written decides what is likely to come next, and that includes your message. A different start gives different odds. There is also a little built-in randomness, controlled by a setting called temperature, so the same question can get two different answers.

From text continuer to chat

A freshly pretrained model only continues text. It is not good at answering questions or following instructions by itself. So it gets more training, for example with human feedback, to behave like an assistant (Anthropic glossary). On top of that, a chat model still only continues a sequence of tokens. The app turns the conversation into one text, often with instructions at the start that you never see (Hugging Face). Anthropic publishes these hidden instructions for its own apps.

Nothing is looked up

On its own, a model does not look anything up. It works from what it learned in training and from the text you give it, its context window, which Anthropic calls a kind of working memory. Some apps add a web search on top. More on that in the guide on today’s news.

Why it writes so well

Google’s course explains that large language models predict far better than older approaches because they have many more parameters and gather far more context. A mechanism called self-attention lets the model ask, for each token, how much every other token affects its meaning. So a word is read in light of the words around it.

Example

You type: “For dinner I’ll order a”. The model weighs many possible next words: “burger”, “pizza”, “salad” and more. Now you type “For dinner I’ll order a green”. The words before the guess changed, so “salad” moves to the top. You did not tell it a fact. You shifted the odds.

What this means for you

  • Sounding sure is not proof. The model picks likely words, not checked ones.
  • What you write steers the answer. A clear message gets a better answer.
  • For exact numbers and letter counts, check yourself.

Sources

What this page rests on. Open the links to read the originals.

The 18 free levels

The free levels behind this guide let you try it hands-on.

  • Level 1: The next word
  • Level 2: A chatbot is not a database
  • Level 8: Word parts, not words
Try it yourself in levels 1, 2 and 8 – free in your browser