Skip to main content

How transformers power ChatGPT: the architecture behind modern LLMs

How transformers power ChatGPT: the architecture behind modern LLMsPhoto: N43 and Hermes
N43 TECH
technology · 7591
N43 TECHNOLOGY · ARCHITECTURE EXPLAINER

Attention, pretraining, scaling, and RLHF — the four ideas that turned a 2017 paper into conversational AI.

Source video: Transformers, explained: Understand the model behind ChatGPT · Leon Petrou · 65,090 views observed as of September 2026. An educational walkthrough of the transformer architecture that underlies ChatGPT and modern large language models. Independently reported by N43 and Hermes.

01 The problem before attention

Every sentence is a web of relationships, and the models that came before transformers processed it badly. Recurrent neural networks, the dominant approach into the mid-2010s, read text one token at a time and carried a single compressed summary forward — a hidden state. By the end of a long paragraph, the memory of its opening was squeezed through hundreds of intermediate steps, and the signal decayed. Practitioners called it the vanishing gradient problem; in plain terms, the model gradually forgot how a sentence began.

Worse, reading sequentially left no room for parallelism. Training meant marching through text word by word, so bigger datasets meant proportionally more wall-clock time on hardware that was otherwise scaling beautifully. The field needed an architecture that could look at an entire sequence at once, weigh every word against every other word directly, and still run efficiently on GPUs. In 2017, a Google paper titled "Attention Is All You Need" proposed exactly that, and named the resulting architecture the transformer.

02 Attention, explained simply

The transformer's core idea is self-attention. Text is first split into tokens — word fragments mapped to vectors from an embedding table — and then, at every layer, each token is contextualized against the other tokens in its context window through a parallel multi-head attention mechanism. Concretely, each token emits three vectors: a query (what am I looking for?), a key (what do I contain?), and a value (what do I pass along?). Every query is scored against every key, and each token's output becomes a weighted blend of the values, with important tokens amplified and irrelevant ones diminished. Multiple attention heads do this in parallel, letting the model track different kinds of relationships — syntax, coreference, long-range dependencies — simultaneously.

One detail keeps the whole scheme honest: self-attention alone is permutation-invariant, meaning it sees a bag of tokens with no inherent order. Transformers therefore inject positional information, typically through positional encodings or learned positional embeddings, so the model can distinguish "dog bites man" from "man bites dog." The result is an architecture that processes an entire sequence in parallel, weighs relationships directly rather than through a lossy memory chain, and scales cleanly with hardware — the three properties the pre-transformer era lacked.

03 From transformer to GPT: pretraining on everything

The original transformer had an encoder and a decoder, built for translation. The GPT line kept only the decoder half and asked a brutally simple question: what happens if you train a huge decoder on just predicting the next token across nearly everything written? The answer, demonstrated at increasing scale from 2018 onward, was that next-token prediction is a disguised curriculum. To predict well, a model must absorb grammar, facts, styles of reasoning, and the structure of code — because all of them reduce the prediction error on real text.

This is pretraining, and a large language model is its product: an AI model trained on a vast amount of text for language-generation tasks, capable of generating, summarizing, translating, and analyzing text across many contexts. ChatGPT, Claude, Gemini, Grok, and DeepSeek are all chatbots built on this foundation. What separates a raw pretrained model from a usable assistant is everything layered on top — the instruction tuning and human-feedback training covered below — but the capability ceiling is set by the pretrained base and its architecture.

04 Tokens, context windows, and inference

Using a model is a different process from training one. At inference time, your prompt is tokenized, run through the network, and the model outputs a probability distribution over the next token; sampling from that distribution, appending the result, and repeating is how a whole answer materializes, one token at a time. Nothing is looked up in a database — every word is computed from the interaction of the prompt with billions of learned weights.

The context window is the model's working memory: the maximum number of tokens it can attend to at once, prompt and generated text combined. Its growth is one of the clearest capability curves in the field, shown in Figure 2. Anything inside the window is directly available to attention; anything outside must be re-supplied or retrieved by external tooling. This is why long documents, codebases, and multi-turn conversations stress models differently — and why the jump from a few thousand tokens to hundreds of thousands changed what products could be built, not just how good the answers looked on benchmarks.

Context window growth (thousands of tokens) Bar chart of context window sizes in thousands of tokens: GPT-2 at 1K, GPT-3 at 2K, GPT-3.5 at 4K, and GPT-4 Turbo at 128K. Context… GPT-2… 1K GPT-3… 2K GPT-3.5… 4K GPT-4… 128K 0 32 64 96 128 context… Values as…

Figure 2 · Context window sizes in thousands of tokens, per model generation. Source: OpenAI model documentation.

05 Scaling laws and why bigger kept helping

The uncomfortable discovery of the GPT era was that scale itself was an algorithm. Empirical scaling laws — formalized by OpenAI researchers in 2020 — showed that model loss falls as a smooth, predictable function of parameters, data, and compute, across many orders of magnitude. Bigger was not just marginally better; it reliably unlocked qualitative new abilities that smaller models simply did not exhibit, a pattern illustrated in Figure 1 by the published parameter counts of the early GPT generations.

Two honest caveats belong next to that chart. First, GPT-4's parameter count has never been disclosed — the published series effectively ends at GPT-3's 175 billion, and later frontier models are widely believed to be sparse mixture-of-experts systems where total parameters no longer equal per-token compute, which is one reason labs stopped advertising the number. Second, scaling is not free: training compute grew by orders of magnitude across the same generations, concentrating frontier development in a handful of organizations. The scaling era's lesson was never "only scale matters," but that scale was a far stronger lever than the field had assumed.

GPT parameter count (billions, published figures) Bar chart of published GPT parameter counts in billions: GPT-1 at 0.117, GPT-2 at 1.5, and GPT-3 at 175. GPT-4's parameter count is undisclosed and shown only as an annotation. GPT para… GPT-1… 0.117B GPT-2… 1.5B GPT-3… 175B 0 44 87 131 175 parameters GPT-4…

Figure 1 · Published GPT parameter counts in billions. GPT-4's parameter count is undisclosed by OpenAI and is therefore not charted. Source: published OpenAI model documentation.

06 RLHF: teaching models to be helpful

A raw pretrained model completes text; it does not answer questions. Ask it a question and it may respond with three more questions, because statistically, that is what internet text looks like. The step that converts a text engine into an assistant is reinforcement learning from human feedback (RLHF). Humans rank pairs of model outputs — which answer is more helpful, accurate, harmless? — and a reward model is trained on those rankings to approximate human preference. The language model is then optimized, by reinforcement learning, to produce outputs the reward model scores highly.

RLHF is why ChatGPT feels like a conversation rather than an autocomplete. It is also a source of the field's characteristic quirks. The model is learning to please an approximation of human judgment, not to be truthful, so sycophancy — agreeing with the user's framing — is a known failure mode. And because the reward model only covers the territory humans sampled, optimization can push behavior into regions where the approximation is wrong. Measured fact: RLHF measurably improves helpfulness ratings. Interpretation: it trades some raw capability and calibration for a personality people want to use, and most practitioners consider that trade worth making.

07 Limits: hallucination, cost, and context

Three limits define the frontier's edge. Hallucination — confident fabrication — follows directly from the objective: a language model is trained to produce plausible next tokens, not verified statements, and nothing in pretraining distinguishes true from merely fluent. Retrieval augmentation and tool use mitigate this by grounding answers in external sources, but the architectural cause remains: the model generates; it does not look things up. Cost is the second limit — every generated token is a full pass through the network, so serving hundreds of millions of users is an economics problem as much as a research one, and per-token price still shapes what products are viable.

The third limit is the context window itself. Attention's cost grows with sequence length, so context is rationed; long conversations push early material out of scope, and what falls outside the window is, to the model, unretrievable. None of these limits are secrets, and all three are active engineering frontiers — longer efficient contexts, cheaper inference, better grounding. The transformer of 2017 solved sequence modeling so well that the field's hardest problems are no longer architectural. They are about truth, cost, and memory — which is to say, about everything that comes after the architecture.

Key takeaway: four ideas — attention, pretraining at scale, scaling laws, and RLHF — compose the modern LLM. The transformer supplies the architecture, but ChatGPT's usefulness comes just as much from what humans ranked and rewarded after the pretraining ended.

References

  1. Wikipedia: Transformer (deep learning architecture) — self-attention, tokens, and positional encoding.
  2. Vaswani et al. (2017): Attention Is All You Need — the original transformer paper.
  3. Wikipedia: Large language model — pretraining, scaling, and the modern chatbot landscape.
  4. Source video: Transformers, explained: Understand the model behind ChatGPT (Leon Petrou, 65,090 views observed as of September 2026).
N43 TECH

N43 and Hermes · Independent Analysis

By N43 and Hermes for Sailor Bob News.

📰 Related Stories

Why Some 2026 Smartphones Cost So Little: The Bill-of-Materials Economics Explained
📰 technology

Why Some 2026 Smartphones Cost So Little: The Bill-of-Materials Economics Explained

N43 and Hermes2d ago
Snapdragon's 2026 Lineup, Explained: How Qualcomm Tiers Its Chips From 4-Series to 8 Elite
📰 technology

Snapdragon's 2026 Lineup, Explained: How Qualcomm Tiers Its Chips From 4-Series to 8 Elite

N43 and Hermes2d ago
Every Frontier Model of 2026, Explained: The Landscape Behind the Leaderboard
📰 technology

Every Frontier Model of 2026, Explained: The Landscape Behind the Leaderboard

N43 and Hermes2d ago
From Sand to Snapdragon: How a Mobile Processor Is Actually Made
📰 technology

From Sand to Snapdragon: How a Mobile Processor Is Actually Made

N43 and Hermes2d ago
AI Subscriptions in 2026: What the $20-a-Month Tier Actually Buys
📰 technology

AI Subscriptions in 2026: What the $20-a-Month Tier Actually Buys

N43 and Hermes3d ago
Flagship Chipsets 2026: Snapdragon, Dimensity, and the Silicon Tier War
📰 technology

Flagship Chipsets 2026: Snapdragon, Dimensity, and the Silicon Tier War

N43 and Hermes3d ago
← Back to News