Skip to content
Lesson 5 · Under the hood

How does ChatGPT work?

ChatGPT works by predicting the next word, over and over, until it has written a whole reply. Underneath it is a large language model: a huge neural network trained on enormous amounts of text. It does not look facts up as it writes. It draws on patterns it learned during training.

Scroll

Autocomplete, but enormous

You already use a tiny language model: the keyboard on your phone. Type "see you" and it suggests "later". It learned that from lots of messages. A large language model, or LLM, is the same idea grown to a huge size. It was trained on a vast slice of the internet, plus books and code, so it can finish an essay instead of a text message. ChatGPT is a chat app built around an LLM. As of 2026 its models come from the company OpenAI; Claude and Gemini are similar apps from other companies. Under the hood, all of them make the same move: given the words so far, what comes next?

How one reply gets written

  1. Your message is chopped into tokens. A token is a small chunk of text, roughly a word or part of a word.
  2. The model reads every token so far and gives a score to every possible next token.
  3. It picks one, usually a high-scoring one with a little randomness, and adds it to the text.
  4. It repeats from the top, one token at a time, until it decides the reply is finished.

Why it sounds so fluent

The model learned from more human writing than any person could read in a thousand lifetimes. So it knows how sentences flow, how an explanation is shaped, how a joke lands. That is why the writing feels natural. But fluent is not the same as correct. The model is choosing likely words, not checking facts. The network design that made this work is called a transformer. Its key trick is called attention: as it picks each token, it can weigh every earlier word in the conversation, so "it" in your question connects to the right thing.

A student who read the whole library

Imagine a student who spent years reading almost every book in a giant library. Then, on exam day, the doors are locked. No notes, no phone. They answer everything from memory. They are brilliant on topics the library covered well, shakier on rare ones, and they know nothing that happened after they stopped reading. That is an LLM answering your question. The training was the reading. The locked door is the moment you press send.

Three limits to keep in mind

  • It does not search the internet while answering, unless the app connects it to a search tool. Many chat apps do this now, but the model itself is not browsing.
  • Its built-in knowledge stops at its training cutoff, the date its training text ends. Ask about last week and it may guess.
  • It has no built-in way to know when it is wrong. A shaky guess comes out just as smoothly as a solid fact.

Your half of the conversation

Everything the model writes is predicted from the words you give it. Change your words and you change the prediction. That makes your message the most powerful control you have, and most people barely use it. The next lesson is about writing it well.

InteractiveType a sentence. See roughly how a model chops it into tokens.

Check yourself · 3 quick questions

  1. What is the basic thing a large language model does?

    Show answer

    Predicts the next token, again and again — An LLM builds a reply one token at a time, each time predicting what most likely comes next from the words so far.

  2. What is a token?

    Show answer

    A small chunk of text, roughly a word or part of a word — Text is chopped into tokens before the model reads it; each token is about a word or a piece of a word.

  3. Why might ChatGPT not know about something that happened last week?

    Show answer

    Because its built-in knowledge stops at its training cutoff — The model only learned from text up to its training cutoff; anything after that it can only guess at, unless the app gives it a search tool.