How ChatGPT Works: Complete Technical Guide
What happens when you send ChatGPT a message: tokens, pre-training, RLHF, reasoning models, routing, web search, memory and the limits you should know.
ChatGPT works by predicting text one small piece at a time. A large Transformer-based language model, trained first on huge amounts of data and then refined with human feedback, takes your message plus surrounding context and generates a reply token by token [1][4]. Around that model, the ChatGPT product adds a lot: a choice of models that think for longer or shorter, tools such as web search, and memory that carries preferences between chats [8][9][10][11].
This guide follows a single message through that stack. If you want the general theory of language models first, read How Large Language Models Work.
The short version
- Your message becomes tokens. Text is split into pieces the model can process [1][2].
- ChatGPT builds a context. It combines your message with conversation history, instructions and, if enabled, memory [11].
- A model is chosen. With GPT-5 in August 2025, OpenAI introduced a router that picks between a fast model and a deeper reasoning model [8]. In September 2026 it retired automatic switching to reasoning for Plus and Pro users, who now choose in the model picker [9].
- The model predicts the next token, again and again. Each token is chosen from a probability distribution, which is why answers vary [1].
- Tools may run mid-answer. The model can search the web and cite sources, among other tools [10].
- The reply streams back to you. The model answers using weights fixed during training; your chat does not retrain it on the spot [1].
Step 1: Text becomes tokens
Models do not read letters or words directly. Text is converted into "tokens," which "may represent whole words, parts of words, or punctuation" [1]. OpenAI's rule of thumb for English is that one token is about four characters, or about three-quarters of a word, so 100 tokens is roughly 75 words [2].
OpenAI's open-source tokenizer library, tiktoken, uses byte pair encoding (BPE), which tries to let the model see common subwords, such as "ing" in English [3]. Tokens matter in practice: context limits, usage limits and API prices are all measured in them. These ratios are only estimates for English; other languages can have different relationships between characters, words and tokens [2].
Step 2: How the underlying model was built
Pre-training: learning to predict
The models behind ChatGPT are Transformer-based models "pre-trained to predict the next token in a document," as OpenAI described GPT-4 [4]. During training, the model sees text such as "Instead of turning left, she turned ___" and learns to predict what comes next. Early on its guesses are "largely random"; over millions of examples, its predictions improve [1].
OpenAI says its training data comes from three sources: publicly available internet content, information accessed through partnerships, and information that users, human trainers and researchers provide or generate [1].
A common misconception is that ChatGPT looks answers up in a stored copy of the internet. OpenAI says its models "do not store or retain copies of the data they are trained on"; instead, training slightly adjusts large sets of numbers, called weights or parameters, to reflect patterns [1]. Our explainer on how Transformer models work covers the attention mechanism that makes this pattern learning possible.
Post-training: learning to be an assistant
A pre-trained model can continue text, but it does not reliably follow instructions. ChatGPT's original recipe, published at launch on November 30, 2022, had three stages [6]:
- Supervised fine-tuning. Human AI trainers wrote conversations, playing both the user and the assistant, and the model was trained on them [6].
- Reward modeling. Trainers ranked several alternative model responses by quality, and those comparisons trained a reward model [6].
- Reinforcement learning. The model was fine-tuned against the reward model using Proximal Policy Optimization, the approach known as reinforcement learning from human feedback (RLHF) [5][6].
The technique came from OpenAI's InstructGPT research, which found that a 1.3-billion-parameter model trained this way produced outputs people preferred to those of the 175-billion-parameter GPT-3 [5]. OpenAI said in its GPT-4 report that post-training improves "factuality and adherence to desired behavior" [4].
Reasoning models: thinking before answering
In September 2024 OpenAI introduced o1, a model "trained with reinforcement learning to perform complex reasoning" that "can produce a long internal chain of thought before responding" [7]. This added a second axis to model quality: besides model size, you can spend more computation at answer time. Reasoning tokens are generated internally and are not shown as answer text [2].
Step 3: Choosing a model
ChatGPT no longer means one model. When OpenAI launched GPT-5 in August 2025, it described "a unified system" with a fast model for most questions, a deeper reasoning model for harder problems, and "a real-time router that quickly decides which to use based on conversation type, complexity, tool needs, and your explicit intent" [8]. Asking it to "think hard about this" was one such signal [8].
That automatic switching has since been scaled back. On September 14, 2026, OpenAI said it was retiring automatic switching from Instant to Thinking (reasoning) for Plus and Pro users globally; they can still pick a model in the model picker to give ChatGPT more time to think, and ChatGPT can still switch automatically for safety purposes [9].
The models change often. As of November 23, 2026, OpenAI's release notes say a version of GPT-6.2 is rolling out in the Chat tab for Plus, Pro, Business and Enterprise users, powered by "a version of GPT-6.2 Sol" tuned for everyday conversation, while the models behind Work and Codex were unchanged [9]. Treat any specific model name as a snapshot as of November 2026.
Step 4: Building the context window
Before the model writes anything, ChatGPT assembles everything it should consider into one input, the context window. That typically includes:
- Your current message and earlier turns in the conversation.
- Instructions from OpenAI and any custom instructions you set.
- Memory, if enabled. OpenAI says memory can draw on past chats, saved memories, custom instructions, saved files and content from connected apps such as Gmail, depending on plan and region [11]. It "does not retain every detail," and ChatGPT decides what is relevant [11].
- Files and images you attach.
The model only "knows" what is in its trained weights plus what is in this context. That is why long conversations can lose track of early details, and why memory and file features exist. Our guide to AI agent memory and context management explains these trade-offs in general terms.
Step 5: Generating the answer token by token
The model computes a probability for every possible next token, picks one, appends it, and repeats. OpenAI explains that because "there are multiple plausible ways to complete a sentence," there is "an inherent element of randomness," and "the same question may yield different answers across different queries" [1].
This process explains both ChatGPT's fluency and its biggest weakness. The model produces the most plausible continuation, which is usually correct but not always. Confident errors, often called hallucinations, are a direct consequence. See What Are AI Hallucinations? for why they happen and how to reduce them.
Step 6: Using tools
Modern ChatGPT does not rely only on what the model memorized during training.
Web search
ChatGPT "may search the web automatically when your question would benefit from current information," or you can choose Web search yourself [10]. Answers that use search may include citations you can open [10]. OpenAI warns that "search results and citations can be incomplete, outdated, or incorrect," and recommends opening sources to check them [10]. This is a form of retrieval-augmented generation; our RAG explainer shows the general pattern.
Other tools
OpenAI describes ChatGPT handling tasks such as analysis, coding support, "completing multi-step tasks across tools" and generating images [1]. Under the hood, tool use follows the function-calling pattern: the model emits a structured request, the system runs the tool, and the result goes back into the context for the next step. Our guide to AI agent tools and function calling explains it.
Step 7: Safety layers
Safety starts with training. At launch, OpenAI said the dialogue format let ChatGPT "admit its mistakes, challenge incorrect premises, and reject inappropriate requests" [6]. OpenAI also publishes some safety evaluation results with new releases. For GPT-6.2 (as of November 2026), it reported that responses met its safety policies 91โ94% of the time in challenging conversations, up from 77โ80% for GPT-6, according to its release notes [9]. Those are OpenAI's own measurements, not independent audits.
What happens to your data
Your messages do not update the model live: OpenAI describes weights being adjusted during training, and the model then uses those learned weights to respond [1]. Separately, conversations may be used to train future models. For individual plans (Free, Plus, Pro), OpenAI says it "may use your content to train our models," and you can opt out with the "Improve the model for everyone" setting [12]. By default, OpenAI says it does not use inputs or outputs from ChatGPT Business, Enterprise, Edu or its API to improve its models [12].
The stack at a glance
Layer | What it does | Why it matters to you |
|---|---|---|
Tokenizer | Splits text into tokens [2][3] | Limits and prices are counted in tokens |
Pre-trained model | Predicts next tokens from patterns in training data [1][4] | Source of general knowledge and fluency |
Post-training (SFT, RLHF) | Teaches instruction following and safer behavior [5][6] | Why it answers like an assistant |
Reasoning | Spends extra computation thinking before answering [7] | Better on math, code and multi-step problems; slower |
Model selection | A router or your model-picker choice selects a fast or a reasoning model [8][9] | Explains varying speed and depth |
Context and memory | Supplies history, instructions and remembered details [11] | Personalization; also privacy considerations |
Tools | Web search, files, code and more [1][10] | Current information and actions beyond text |
Limitations to keep in mind
- It can be wrong with confidence. Next-token prediction optimizes plausibility [1].
- Citations need checking. Search results can be incomplete or outdated [10].
- Answers vary. The same prompt can produce different replies [1].
- Context is finite. Very long chats and large files may exceed what the model considers at once.
- Models change frequently. Behavior can shift between releases [9].
Frequently asked questions
Does ChatGPT search the internet for every answer?
No. It answers from its trained model by default and searches the web when the question benefits from current information or when you select Web search [10].
Does ChatGPT learn from my conversations in real time?
No. The model responds with weights learned during training; chatting does not retrain it [1]. Memory can store details for later chats if enabled [11], and conversations from individual plans may be used to train future models unless you opt out [12].
What does GPT stand for?
Generative Pre-trained Transformer: it generates text, is pre-trained on large datasets, and uses the Transformer architecture [4].
Why does ChatGPT give different answers to the same question?
Generation involves choosing among plausible next tokens, so there is randomness built in [1]. A different model, whether picked by you or by automatic routing, can also change the result [8][9].
What is RLHF?
Reinforcement learning from human feedback. People rank model responses, a reward model learns those preferences, and the language model is optimized toward them [5][6].
Which model does ChatGPT use right now?
It depends on your plan and the mode you choose, and it changes often. As of late November 2026, a version of GPT-6.2 was rolling out in the Chat tab for Plus, Pro, Business and Enterprise users, while ChatGPT Work and Codex use GPT-6.2 Astra and Sol in preview [9].
Sources
- OpenAI Help Center, "How ChatGPT and our foundation models are developed." https://help.openai.com/en/articles/7842364-how-chatgpt-and-our-foundation-models-are-developed
- OpenAI Help Center, "What are tokens and how to count them?" https://help.openai.com/en/articles/4936856-what-are-tokens-and-how-to-count-them
- OpenAI, "tiktoken" (GitHub README). https://github.com/openai/tiktoken
- OpenAI, "GPT-4 Technical Report," arXiv:2303.08774. https://arxiv.org/abs/2303.08774
- Ouyang et al., "Training language models to follow instructions with human feedback," arXiv:2203.02155. https://arxiv.org/abs/2203.02155
- OpenAI, "Introducing ChatGPT" (November 30, 2022). https://openai.com/index/chatgpt/
- OpenAI, "Learning to reason with LLMs" (September 12, 2024). https://openai.com/index/learning-to-reason-with-llms/
- OpenAI, "Introducing GPT-5" (August 7, 2025). https://openai.com/index/introducing-gpt-5/
- OpenAI Help Center, "ChatGPT release notes." https://help.openai.com/en/articles/6825453-chatgpt-release-notes
- OpenAI Help Center, "Searching the web with ChatGPT." https://help.openai.com/en/articles/9237897-chatgpt-search
- OpenAI Help Center, "Memory in ChatGPT." https://help.openai.com/en/articles/8590148-memory-faq
- OpenAI Help Center, "How your data is used to improve model performance." https://help.openai.com/en/articles/5722486-how-your-data-is-used-to-improve-model-performance