ChatGPT explained: the architecture and training loop behind the frontier-LLM race
Photo: N43 and Hermes AINext-token prediction, attention, and the training loop: the mechanics behind ChatGPT and the frontier-LLM release race, explained from first principles.
Source video: Let's build GPT: from scratch, in code, spelled out. · Andrej Karpathy · approximately ~8.4 million views, uploaded 2023-01-17, observed 2026-11-29. The lecture is an evergreen build-from-scratch walkthrough of exactly the mechanism behind every frontier release, and it is contextualized here against the 2026 release race. Independently researched by N43 and Hermes AI.
01 What a language model actually computes
Strip away the chat interface and a model like ChatGPT reduces to a single, almost banal operation: given a sequence of tokens, predict the distribution over what comes next. Everything else — reasoning, code, translation — emerges from repeating that operation across billions of parameters. The framing matters because it makes the system measurable: next-token prediction is formally equivalent to compression, and a model that predicts well is, by definition, a model that has learned a lot about its training distribution.
The vocabulary being predicted over is not words but tokens — subword units produced by a fixed tokenizer, typically three-quarters of a word or so in English. A prompt is tokenized, fed through the network, and the output is a probability vector over roughly 100,000 possible next tokens. Sampling from that vector, appending the chosen token, and repeating is the entire generation loop. Chat is a product decision layered on top of an autoregressive engine that never stops predicting the next token.
02 Pretraining: corpus, objective, and what scale buys
Pretraining is the phase where the model acquires almost everything it will ever know. The objective is unchanged from GPT-1: cross-entropy loss on next-token prediction, applied to trillions of tokens of web text, books, and code. What changed between generations is mostly scale — parameters, data, and compute moving up together roughly in line with the scaling laws that predicted loss would fall as a smooth function of all three.
Scale buys capability in lurches that researchers still argue about. Some abilities appear to improve predictably with size; others show abrupt jumps that earned the name emergent. What is not disputed is that the published curve flattened for no one: each successive generation of frontier models raised the compute bill by orders of magnitude. The chart below covers the last models whose parameter counts were publicly documented — since GPT-4, flagship sizes have become trade secrets.
03 Inside the transformer: attention, context windows, and the KV cache
The transformer, introduced in 2017, replaced recurrence with attention: every token can look directly at every earlier token and weigh how much each one matters. Stacking dozens of such layers lets the model build representations that track syntax, topic, and reference across long spans. The context window — how many tokens attention can span at once — has become a headline specification, climbing from a few thousand tokens in early GPT-3 to hundreds of thousands in current frontier systems.
Inference speed comes from an unglamorous optimization: the key-value cache. Because attention over previous tokens never changes once those tokens are processed, their keys and values are stored and reused instead of recomputed for every new token. The trick makes generation feasible but trades memory for speed — cached context grows linearly with conversation length, which is why long-context features arrive alongside heavier serving hardware rather than for free. Attention arithmetic still scales with sequence length squared in the naive form.
04 Post-training: instruction tuning, RLHF, and why alignment shapes voice
A freshly pretrained model completes text; it does not follow instructions. Post-training closes that gap in stages. Supervised fine-tuning first teaches the format with curated question-and-answer examples. Reinforcement learning from human feedback then optimizes against a reward model trained on human preferences, which is where the model learns to refuse, hedge, and adopt a consistent voice. The assistant persona users experience is largely a product of this stage, not of pretraining.
This is why competing assistants feel different despite similar raw capability: alignment choices are editorial. How deferential the model is, how it handles controversy, how much personality it projects — those are reward-model decisions with commercial stakes attached. Post-training also has costs. Reward models can be gamed, producing sycophancy or over-refusal, and the details of every major lab's recipe are closely held, which makes public reproduction of alignment behavior rare.
05 The 2026 frontier race: what releasing a model now means
By 2026, releasing a frontier model is a product launch with a standard checklist. Published benchmark scores — MMLU-style knowledge tests, coding suites, math — anchor the announcement. Agentic evaluations that score multi-step tool use have joined them, because the commercial story has shifted from chat to agents that complete work. Pricing tiers, context-window sizes, and rate limits ship in the same press release, because each model now arrives as a segmented product line rather than a single endpoint.
The race itself has changed shape. Release gaps between the major labs have compressed to months, and each launch now targets a specific competitor's pricing tier as much as its benchmark numbers. Open-weight releases from Chinese and European labs have added a second axis of competition: capability per dollar rather than capability alone. For buyers, the practical question is no longer which lab is ahead in the abstract, but which model clears a workload's quality bar at the lowest serving cost.
06 Inference economics: per-token costs, serving infrastructure, and the price-collapse curve
Frontier capability would matter less if serving it stayed expensive, and the defining economic fact of the decade is that it did not. Between GPT-3's Davinci endpoint in 2020 and GPT-4o mini in 2024, the list price of a million output tokens fell from sixty dollars to fifteen cents — a 400-fold decline in four years, charted above on a log scale and achieved through distillation, quantization, speculative decoding, and brutal infrastructure competition.
The decline reshapes product strategy. Applications that were uneconomic at Davinci pricing became trivial at GPT-4o mini pricing, and each collapse wave created new categories overnight. The frontier tier stays expensive — that is where the margin funds the next training run — while last year's flagship becomes this year's bulk tier. Serving economics, not research headlines, increasingly decide which models actually get deployed at scale.
07 Limits: hallucination, context debt, and why evaluation is hard
The core failure mode is hallucination: fluent, confident output that is simply false. It follows directly from the objective — a model trained to produce plausible continuations has no built-in notion of truth, only of likelihood. Retrieval augmentation and tool use reduce the exposure by grounding answers in checked sources, but the underlying mechanism is unchanged, and no released frontier model has solved it.
Evaluation is harder than it looks. Benchmarks leak into training data, so headline scores drift upward partly through contamination; models can be tuned toward known test formats. Long conversations add context debt — earlier errors and stale premises accumulating in the window, degrading later output in ways single-turn tests never measure. Careful buyers therefore evaluate on private, task-specific suites that mirror their real workload, and treat public leaderboards as a first filter rather than a verdict.
References
- Wikipedia: Large language model
- Wikipedia: Transformer (deep learning architecture)
- Brown et al.: Language Models are Few-Shot Learners (GPT-3)
- Source video: Let's build GPT: from scratch, in code, spelled out. (Andrej Karpathy, ~8.4M views, observed 2026-11-29)
By N43 and Hermes AI for DutyStation News.





