Skip to content
Giallo

How ChatGPT Works

How ChatGPT works, explained simply: token prediction, training, RLHF, the context window, real limitations and effective business use.

Reading time: 10 min

Scheme of how ChatGPT works: from the prompt to the prediction of the next token until the generated response

ChatGPT works much more simply than it seems: at each step it predicts what the next word more likely and adds it to the answer, one after the other. It does not look for the answer in an archive and does not reason like a person. It is a Large Language Model (LLM) trained on huge amounts of text, which has learned the statistical patterns of language and uses them to continue a text in the most plausible way.

Understanding this mechanism changes the way you use it. If you know that ChatGPT produces the continuation more likely — not that certainly true metti stop treating it like an oracle and start using it as a quick tool but to control. Most use errors arise from not knowing what is under the hood.

In this guide we see, in a way accessible even to those who are not technical, how ChatGPT works step by step: what is a token, how does prediction happen, how has the model been trained, what does the RLHF, what is the context window and why all this matters when you bring it into everyday work.

In summary

  • ChatGPT is a LLM which generates text predicting, one step at a time, the next token more likely given all the previous text.
  • Work on Token (fragments of word), not on whole words: it is the unit with which you read your text and construct the answer.
  • He has been trained in several stages: pre-training on large amounts of text, then fine-tuned and RLHF (human feedback) to make it useful and safe.
  • The context window is how much text he can keep in mind at once: past the limit, the older parts come out of the active memory.
  • Produce the answer more likely, not the verified one: it can be wrong with confidence, so it should always be checked on the critical points.

What is ChatGPT, in one sentence

ChatGPT is an application built over a large language model developed by OpenAI. The "GPT" stands for Generative Pre-trained Transformer: a generative model, pre-trained on text, based on an architecture called Transformer. In practice it is a system that, given an input text (your message), generates an output text (the answer) continuing it in the most statistically plausible way.

The family of models to which it belongs is that of Language Models (LLM): the same category as Claude and Gemini. If you want a general overview of the instrument, plans and use cases, you can find it in the guide ChatGPT: what it is and how to use it. Here instead we dig into the mechanism.

How ChatGPT works step by step

The heart of ChatGPT is a surprisingly simple idea repeated millions of times: predict the next piece of text. Let's see the flow, from your message to your response.

  1. Tokenization. Your text is broken into Token, that is word fragments. "Automation" can become two or three tokens; a space and a comma are tokens in turn. The model does not see letters or whole words, it sees token sequences.
  2. Numerical coding. Each token is transformed into numbers (vectors). This is how language enters a mathematical function: the model works only on numbers.
  3. Prediction of the next token. The neural network calculates, for every possible token in its vocabulary, how much is likely to come next. It gets a list of candidates with their respective probabilities.
  4. Token choice. One of the most likely candidates is selected (with a small dose of controlled randomness, not to be always identical). This token becomes the first part of the response.
  5. Repeat. The newly chosen token is added to the text and the process starts again: new prediction, new token. Phrase after sentence, until the answer is complete.

That's all. There's no database of answers ready, there's no search: there's a Next token prediction repeated at very high speed. The reason the answers seem "intelligent" is that the model, in order to predict the word after well, had to learn grammar, recurring facts, styles and argumentative structures present in the text on which it was trained.

Because it works on tokens and not words

Working at Token makes the model more efficient and flexible: it handles rare words, typos, different languages and code without having to know every word in advance. This detail is not just theory: tokens are also the unit by which the cost and length are measured of conversations. If you want to understand why they matter (even economically), there is the dedicated guide on what are AI tokens.

To remember ChatGPT doesn't "know" the answer and then writes it to you. It builds the response as it generates it, token after token. It is the reason why it sometimes starts well and then gets lost: every new piece depends on those first.

How ChatGPT was Trained

The ability to predict the next token well does not arise from nothing: it is the result of a Training in several stages. Understanding them helps to understand both the strengths and limitations of the model.

Phase 1 Pre Pre-training (learn the language)

The model is exposed to huge amounts of text and trained on only one task: predicting the next token. By misreading and correcting itself billions of times, it adjusts its internal parameters until it learns grammar, facts, ways of saying and structures of language. At the end he has a broad general knowledge, but he is "raw": he tends to continue the text, not to respond in a useful way.

Step 2 — Set up on instructions (learn to answer)

The model is further trained on examples of quality instructions and responses, written or selected by people. So he learns to behave like an assistant: understand a request, follow a format, give a relevant answer instead of just continuing the text.

Phase 3 — RLHF, human feedback (learn what is "good")

RLHF means learning by reinforcement from human feedback. People compare more responses than the model and indicate which ones are better (clearer, useful, safe). From these preferences a signal is built that guides the model towards more welcome and less problematic responses. It is the phase that gives ChatGPT its tone and its "education".

The important point: training stops at a certain date. The basic model does not know the next events and don't "learn" from your conversations in real time. Some versions can search the web or read the files you upload, but the functions depend on the plan and change often: always check the official OpenAI page to know what is active in your account.

What is the context window

The context window is one of the most useful things to understand to use ChatGPT well. It is the maximum amount of text, measured in tokens, which the model can consider at once: includes your message, any system instructions and conversation history.

Imagine it as a desk of fixed size. As long as the sheets fit, the model sees everything. When you add too much text, the older sheets fall off the edge: they come out of active memory and the model stops taking them into account. That's why in a very long conversation ChatGPT may seem to "forget" something said at first: it didn't erase it by choice, it just doesn't fit in the window anymore.

Appearance What it means in practice
Unit of measurement Tokens, not words or characters. Long documents consume many tokens.
What it contains Instructions, your message and chat history: everything competes for the same space.
Limit exceeded The older parts come out of context; the model no longer considers them.
Typical effect In long chats it seems to "forget" initial details or repeat itself.
How to manage it Summarize key points, paste only relevant parts, open a new chat when changing theme.

The Context Window is not permanent memory: it is temporary working memory, valid for that conversation. Some versions offer "memory" functions between different chats, but they are a separate mechanism and need to be verified on the plan in use.

Why ChatGPT sometimes gets it wrong (and with confidence)

If you have followed this far, the source of the errors is clear: ChatGPT produces the continuation more likely, not that true. When a false formulation "sounds well" statistically, the model generates it with the same safe tone as a correct one. This phenomenon is called hallucination: the model invents names, numbers, quotations or sources that do not exist, presenting them as facts.

It is not a "bug" defect: it is a direct consequence of how it works. This is why it must be managed with method — asking for the sources, providing the data in the prompt, verifying the numbers. The dedicated guide on how to avoid AI hallucinations explains the practical techniques. And since the quality of the answer depends a lot on how you ask the question, it is worth starting from the basics of prompt engineering.

Practical examples

Two concrete scenarios to see what changes when you understand the mechanism.

1. Professional study — summary of a contract. An assistant pastes a contract and asks ChatGPT for a summary. Knowing that the model works in the context window, it pastes only the relevant clauses instead of the whole faldon: the result is more precise and does not risk "losing" parts to exceed the limit. And knowing that the model can hallucinate, it verifies deadlines and amounts them against the original text, instead of trusting in a closed box.

2. E-commerce — product descriptions. The team asks for a first draft description starting from the actual data sheet, pasted into the prompt. Since the model provides the most plausible text, providing it with true data (materials, measurements, uses) keeps it anchored to facts and prevents it from inventing features. The person sees and publishes. Without this, ChatGPT would fill in the blanks with invented but "likely" adjectives.

In both cases the difference is not ChatGPT: it is the one who uses it knowing how he reasons.

Mistakes to Avoid

  • Treat it like a search engine. ChatGPT does not query an up-to-date archive: it provides text. On recent facts or precise data, always check or provide the source.
  • Pasting entire documents without criterion. Beyond the context window, older parts disappear. Better select relevant sections or work by blocks.
  • Expecting me to remember previous chats. Except for specific memory functions, each conversation starts "clean". What is not in context, for the model does not exist.
  • To give every sure answer as true. Convinced tone is not an indicator of correctness. Numbers, standards and customer data should be verified by hand.
  • Entering sensitive data without rules. Uploading personal data of customers into a public tool can violate the GDPR. We need a clear policy on what you can and can't share.

How to apply it in the company

Understanding how ChatGPT works is not technical curiosity: it is what allows you to use it reliably in processes. Here is how to translate it into practice in an SME.

  • Always provide the context in the prompt (data, examples, expected format): the model still the answer to what you give it, reducing inventions.
  • Keep Requests inside the context window: long documents should be divided or summarized, not glued whole.
  • Always put one Human Review on critical points: numbers, clauses, customer communications.
  • Define a data rule: what is forbidden to paste (customer records, secrets) and what is allowed.
  • When a use is repeated every day, it evaluates to structure it into a stream instead of copying and pasting by hand each time.

The last point is what makes the difference for a company. Using ChatGPT by hand is great for trying, but when a task repeats dozens of times a day it is best to turn it into a process connected to your tools — a AI Agent or a Automation which receives the data, processes it with the model and returns the result where it is needed, with the right controls. It is the transition from "playing with ChatGPT" to "AI in processes". If you want a wider overview, there is the guide ChatGPT for companies, and applied experiments we tell them in The Lab.

ChatGPT by hand is fine when

  • Use is occasional or exploratory.
  • Each request is different from the others.
  • The person controls and refines each output.
  • You don't need integrations with your systems.

Needs a structured flow when

  • The same activity is repeated many times a day.
  • Data comes from email, management software or CRM.
  • You want traceability and repeatable controls.
  • The result must end in another software.

For updated numbers and model by model comparison, GPT-6 Astra vs Gemini 3.1 Pro and Claude Opus 5 vs GPT-6 Astra.

Conclusion

ChatGPT works by predicting the next most likely token, one step at a time, based on the patterns learned during training and honed with the RLHF. It does not search, reason and remember beyond its context window: it generates the most plausible continuation of the text you give it. Knowing this is exactly what you need to use it well — taking advantage of its speed on first drafts and keeping the person where verification and judgment are needed. From here you can continue with the theoretical basis on the LLM or with the concrete difference between the plans in Free ChatGPT vs Plus.

If you want to go from testing with ChatGPT to an AI system integrated into business processes, Giallo Studio custom designed agents and automations.

Giallo Studio guides: methodology and sources

How we apply it in the company

Related resources

AI consulting services and process automation

FAQ

How does ChatGPT work in simple terms?

ChatGPT is a language model that generates an answer one word (more precisely, one token) at a time. At each step, it calculates which token is most likely to come next given all the preceding text, and adds it. Repeating this process many times builds complete sentences. It does not search a database for information or “understand” like a person: it predicts the most plausible continuation based on what it learned during training.

Does ChatGPT really understand what it writes?

No, not in the human sense. ChatGPT has no awareness or understanding of meaning: it recognizes statistical patterns in language and produces the most likely output. Often the result is correct and useful, but the model can also generate false information with the same confident tone. For this reason the answers must be verified, especially on data, numbers and regulations.

What is the ChatGPT context window?

The context window is the maximum amount of text (measured in tokens) that ChatGPT can consider at once: your message, the instructions, and the conversation history. When this limit is exceeded, the oldest parts leave the active “memory” and the model stops taking them into account. That is why, in long conversations, it may seem to “forget” things said at the start.

What is RLHF and why does it matter?

RLHF means reinforcement learning from human feedback. It is a training stage in which people evaluate and rank the model’s answers, teaching it which are more useful, clear, and safe. This is why ChatGPT responds conversationally and follows instructions, instead of simply completing text in the unrefined way a base model would.

Is ChatGPT connected to the internet, and does it know what is happening today?

The base model has a training date beyond which it does not know the events. However, some versions and functions can search the web or read files you upload. The available functions often change depending on the plan: always check the official OpenAI page to know what is included in your account.

Why does ChatGPT sometimes give different answers to the same question?

Because the generation includes a controlled random component: at each step the model does not always choose the single most likely token, but samples among the most plausible candidates. This makes the answers more natural and varied, but also means that the same question can produce different formulations at different times.

Put it into practice

Let's turn this guide into your first live workflow.

Tell us what process you want to lighten: we evaluate feasibility, return and first operational step.