How ChatGPT Works In Steps

4:45 PM PKT 10 min read

A chat window on a laptop screen showing a question being typed, with words appearing one by one in the answer below it.
In this post
  1. Step One: Your Words Become Tokens
  2. Step Two: The Model Reads The Context
  3. Step Three: Predicting The Next Token
  4. Step Four: One Token At A Time, Many Times
  5. Step Five: Tools, Retrieval And Memory
  6. Step Six: Safety Filters And Formatting
  7. Why It Sometimes Gets Things Wrong
  8. What ChatGPT Does Not Do

You type a question into a box, press enter, and words begin to appear on the screen, one by one, as if someone is typing them in real time. It feels like a conversation. It is not a conversation in the human sense. It is a machine predicting words, one after another, based on patterns it learned from an enormous amount of text. This post explains, in simple words, how ChatGPT works, step by step, from the moment you press enter to the moment the answer is complete.

Step One: Your Words Become Tokens

The first thing that happens is that your text is broken into pieces called tokens. A token is not quite a word and not quite a letter. It is a chunk of text, often a whole common word, sometimes part of a word. The word “unbelievable”, for example, might be split into “un”, “believ” and “able”. ChatGPT does not read sentences the way you do. It reads tokens, and each token becomes a number that the model can work with.

Tokenisation matters because it is how the model sees your question. The same sentence can be split into different numbers of tokens depending on the words used, and longer, rarer words use more tokens. It is also why ChatGPT has a limit on how much text it can consider at once: the limit is counted in tokens, not in words, and when the conversation gets too long, the oldest tokens fall out of the model’s view.

Step Two: The Model Reads The Context

Next, the model reads your tokens together with the context of the conversation. The context includes the system prompt, which is a hidden set of instructions that tells the model how to behave, and the earlier messages in the conversation, so that it can remember what you were talking about. A guide published on DEV in April 2026 describes this as context building: the model gathers the conversation history, the system instructions, and any extra information from tools or memory, and assembles them into a single input.

This step is why ChatGPT can follow a conversation. It does not have a memory in the human sense, but it can see the previous messages in the context, and it uses them to shape its reply. When the context gets too long, the system must choose what to keep and what to drop, which is why a very long conversation can lead the model to forget something you said at the start. The context is the model’s short-term memory, and it is limited.

Step Three: Predicting The Next Token

The heart of ChatGPT is prediction. The model has been trained on a massive amount of text — books, articles, websites, and other writing — and from that training it has learned the patterns of language: which words tend to follow which other words, in which contexts. When it needs to answer, it looks at all the tokens so far and calculates, for every token in its vocabulary, how likely that token is to come next. Then it picks one, usually the most likely, sometimes a slightly less likely one to add variety.

This is the point that most explanations get wrong, or leave out. ChatGPT does not look up the answer in a database. It does not know facts the way a person knows them. It predicts the next token, then feeds that token back in and predicts the next one, and so on, until the answer is complete. IBM’s explanation of AI hallucinations puts it plainly: the model predicts the next token based on patterns in its training data, without an internal sense of what is true. The text it produces can be fluent and confident, and still be wrong, because fluency and truth are not the same thing.

Step Four: One Token At A Time, Many Times

The answer appears one token at a time because that is how it is made. The model generates the first token, adds it to the input, generates the second, adds that, and repeats the process hundreds or thousands of times. That is why the words appear on screen gradually, as if being typed. The streaming display is not a trick. It shows the generation happening in real time, token by token.

The number of tokens in an answer affects how long it takes and how much it costs to run. A short answer may use a few dozen tokens. A long answer may use thousands. The model does not plan the whole answer in advance, in the way a writer plans an essay. It builds the answer as it goes, one prediction at a time, which is why it can sometimes start well and wander, or contradict itself partway through. It is improvising, brilliantly, but improvising all the same.

Step Five: Tools, Retrieval And Memory

In real systems, the model does not work alone. The DEV guide describes how a production system adds tools around the model: retrieval, which fetches relevant documents from a database or the web, so that the model has facts to work with; memory, which stores information about the user across conversations; and tools, which let the model do things such as search the web, run code, or check a calendar. When ChatGPT searches the web for you, it is using a tool to fetch information, then feeding what it found into the context, and then predicting an answer based on that context.

Retrieval is the most important of these additions, because it addresses the model’s biggest weakness: its training data has a cut-off date, and it does not know what happened after that date. By fetching current information and putting it into the context, retrieval lets the model answer questions about recent events. It does not make the model know the facts. It gives the model text to base its predictions on, which is a different and more limited thing, but it is much better than guessing.

Step Six: Safety Filters And Formatting

Before the answer reaches you, it passes through safety filters and formatting. Safety filters check the answer for content that should not be shown, such as instructions for wrongdoing, and either block it or replace it with a refusal. Formatting turns the raw tokens into the readable answer you see: paragraphs, headings, lists, and code blocks. The model itself generates the formatting marks, such as the symbols for a heading or a list, as part of its token predictions, and the display system renders them.

The safety system is not perfect. It can block harmless requests and miss harmful ones, and it is a subject of constant adjustment. But it is a real part of how ChatGPT works, and it explains why the system sometimes refuses a request that seems innocent, or gives a partial answer where a full one was expected. The model predicted an answer, and the safety layer decided that answer should not be shown, or should be shown in a different form.

Why It Sometimes Gets Things Wrong

ChatGPT gets things wrong for reasons that follow directly from how it works. Because it predicts the next token from patterns, it can produce text that sounds right but is factually wrong, a problem called hallucination. IBM’s guide explains that hallucinations happen because the model has no built-in sense of truth, and because its training data can contain errors, gaps, and outdated information. The model can also invent sources, citing books or articles that do not exist, because a citation looks like a plausible next token, even when the source is imaginary.

The other common failure is outdated information. The model’s training data ends at a cut-off date, so it does not know about events after that date unless retrieval brings it current information. A question about this week’s news, asked without web access, will get an answer based on old patterns, which may be confidently wrong. The fix is to check the answer against a reliable source, especially for facts that matter. ChatGPT is a tool for drafting, explaining and brainstorming. It is not a reliable source of facts on its own.

What ChatGPT Does Not Do

ChatGPT does not think the way a person thinks. It does not understand the world, have beliefs, or know what it is saying. It does not feel, intend, or remember in the human sense. It processes tokens, calculates probabilities, and generates text. The DEV guide’s summary is honest: the model “doesn’t think like a human”. It simulates understanding by predicting what a helpful answer would look like, based on the patterns of millions of human texts.

That limitation is also its strength. Because it has seen so many patterns, it can write in many styles, explain many subjects, translate between languages, and help with tasks from coding to cooking. The skill is real. The understanding behind it is not. Knowing the difference is the key to using ChatGPT well: trust it for drafting and explaining, verify it for facts, and never treat a fluent answer as proof that the answer is true.

Frequently Asked Questions

How does ChatGPT work in simple words?

ChatGPT works by predicting words, one token at a time. Your text is broken into tokens, the model reads them together with the conversation context and any hidden system instructions, and then calculates which token is most likely to come next, based on patterns learned from a massive amount of training text. It picks a token, feeds it back in, predicts the next one, and repeats the process until the answer is complete. It does not look up answers in a database, and it does not know facts the way a person does. It predicts what a helpful answer would look like.

Does ChatGPT understand what it says?

No, not in the human sense. ChatGPT does not understand the world, have beliefs, or know what it is saying. It processes tokens, calculates probabilities, and generates text that follows the patterns of human writing. It simulates understanding by predicting what a helpful answer would look like, based on millions of human texts it was trained on. That is why it can be fluent and confident and still be wrong: fluency and truth are not the same thing, and the model has no internal sense of what is true.

Why does ChatGPT sometimes give wrong answers?

ChatGPT gives wrong answers because it predicts the next token from patterns rather than checking facts. When its training data contains errors, gaps, or outdated information, the predictions can be wrong, producing text that sounds right but is factually incorrect, which is called a hallucination. It can also invent sources that do not exist, because a citation looks like a plausible next token. Its training data also has a cut-off date, so without web retrieval it does not know about recent events. The fix is to check important facts against a reliable source.

What is a token in ChatGPT?

A token is a chunk of text that the model works with, often a whole common word and sometimes part of a word. The word unbelievable, for example, might be split into un, believ and able. ChatGPT reads tokens, not sentences, and each token becomes a number the model can calculate with. Limits on how much text the model can consider are counted in tokens, not words, and longer or rarer words use more tokens. The answer is also generated one token at a time, which is why the words appear gradually on screen.

Can ChatGPT browse the internet?

In real systems, ChatGPT can use tools, including web search, to fetch current information and add it to the context before predicting an answer. That process is called retrieval, and it helps with questions about recent events that are beyond the model’s training cut-off date. But retrieval does not make the model know the facts. It gives the model text to base its predictions on, which is better than guessing but still limited. The answer should still be checked against a reliable source for facts that matter.

Sources

💬 Leave a CommentYour email address will not be published. Required fields are marked *
Back to all posts