5.3 Model landscape and lifecycle
This part of Foundation Models and Architectures develops the mechanisms below. Work the numerical examples or trace the code before checking the answer.
Concepts from other sections (18)
This section uses these ideas. Each has a short definition and a link to the section that explains it in full. Tap a dotted term in the text to preview it.
- Model card: the model’s interface documentation: details, intended and out-of-scope use, evaluation with uncertainty, limitations, and data. Read more: 35.1 Datasheet and model card
- Mixture of experts (MoE): a layer of many expert MLPs of which a router picks per token. Read more: 13.8 Mixture of Experts
- Active parameters: parameters participating in the computation for a particular token. Read more: 20.9 Architecture choices and performance limits
- GGUF: llama.cpp’s single-file quantized model container, readable across llama.cpp, candle, mistral.rs, and Zig bindings. Read more: 20.2 Inference Frameworks: The Cross-Language Landscape
- DPO: minimizing over preference pairs, equivalent to fitting the KL-regularized reward objective. Read more: 18.2 Direct preference optimization and IPO
- GRPO: a PPO-style RL method that replaces the critic with the group-normalized reward of several samples of the same prompt. Read more: 19.7 The training step and validation
- dual encoder: two towers, one per modality, projecting into a shared embedding space. Read more: 14.5 Contrastive image-text: CLIP and SigLIP
- Exponential moving average (EMA): the recursion , a weighted sum with geometric weights. Read more: 8.2 Series convergence, the EMA as a geometric series, and bias correction in Mathematics
- Chinchilla-optimal: the compute-optimal split that minimizes loss for a fixed training budget. Read more: 19.7 The training step and validation
- PPO: a policy gradient method that clips the new-to-old probability ratio to keep updates small. Read more: 4.4 World models, multiple agents, and RLHF
- KV cache: per-layer storage of past keys and values, so each decode step processes only the new token. Read more: 21.2 The KV cache, incremental decoding, and generate
- DRY: every piece of knowledge has a single, unambiguous representation in the system. Read more: Chapter 1: The Pragmatic Programmer in Software Engineering
- Scaling laws: empirical power laws relating loss to compute, data, and parameter count. Read more: Chapter 2: Deep Learning
- FlashAttention: attention computed tile by tile with an online softmax, so the score matrix is never stored. Read more: 22.5 FlashAttention forward in C
- KL divergence: , the excess cost of predicting with ; nonnegative and asymmetric. Read more: 17.1 Entropy, cross-entropy, KL, JS, and the k3 estimator in Mathematics
- Entropy: , the average surprise of a distribution. Read more: 17.1 Entropy, cross-entropy, KL, JS, and the k3 estimator in Mathematics
- RMSNorm: divides a vector by its root mean square plus eps (inside the root) and multiplies by a learned gain; no mean subtraction, no bias. Read more: 13.1 Pre-LN and RMSNorm
- Multi-query attention (MQA): all query heads share one key/value head. Read more: 13.5 Grouped-Query Attention with a Cache Hook, Windows, and Sinks
Learning objectives
- Read model examples as architecture and training decisions rather than a fixed leaderboard.
The model landscape in 2026
Section titled “The model landscape in 2026”With the architectures in hand, you can read the current models as combinations of these choices. These are the main open-weight families; for each, read the tech report and model card:
| Family | Notable variants | Architectural notes |
|---|---|---|
| Gemma (Google) | 3 (270M/1B/4B/12B/27B), 3n (E2B/E4B, MatFormer + per-layer embeddings, edge), 4 (E2B/E4B/26B-MoE/31B-dense, native audio + video), PaliGemma, MedGemma, CodeGemma, ShieldGemma, RecurrentGemma | multimodal, local+global attention, single-GPU focus |
| Llama (Meta) | 3.x, 4 (MoE) | the reference open decoder-only recipe |
| Qwen (Alibaba) | dense + MoE, VL, audio | strong multilingual + multimodal |
| DeepSeek | V3/R1 (MLA + fine-grained MoE) | MLA attention, reasoning (RL) |
| Mistral | 7B, Mixtral (MoE), sliding-window | efficiency-focused |
| Phi (Microsoft) | small, data-curated | “textbooks” data quality over scale |
The closed, frontier models, GPT (OpenAI), Claude (Anthropic), and Gemini (Google), are API-only, larger, and multimodal.
To read any model, check its size and active parameters (dense or MoE), its context length, its attention type (GQA, MLA, or sliding-window), its modality support, its license, and the availability of quantized GGUF or other checkpoints, which decides whether you can actually run it; see Quantization: Math to Code.
The LLM development lifecycle
Section titled “The LLM development lifecycle”The architecture tells you what a model is. The final question is how one comes to exist, and here the right mental model departs sharply from ordinary software. In traditional software you write the behavior: a human encodes rules as deterministic code. In an LLM you grow the behavior: a pipeline of learning paradigms turns a corpus into weights, and the behavior is whatever statistically emerged. Behavior is emergent rather than specified, which is why “testing” becomes evals and “bug fixes” become more data and more alignment. This is the deepest shift in the chapter, so treat the two lifecycles as genuinely different engineering disciplines, not the same one with a neural network swapped in. The account here draws on Karpathy’s State of GPT, Huyen’s AI Engineering, and the Llama 3 tech report.
The four learning paradigms
Section titled “The four learning paradigms”The paradigms differ only in where the training signal comes from, and each owns a stage of the lifecycle:
| Paradigm | Where the label comes from | Lifecycle stage | Deeper treatment |
|---|---|---|---|
| Unsupervised | no labels: structure in the data itself (clustering, dedup, topic balance) | Corpus curation & data engineering | Unsupervised learning |
| Self-supervised | labels derived from the data (predict the next token / a masked span / a held-out view) | Pretraining (the expensive 99%) | Representation learning |
| Supervised | curated human input→output pairs | SFT / instruction tuning | Statistical Learning |
| RL from feedback (RLHF / RLAIF / DPO / GRPO) | a preference or reward signal over whole outputs | Preference optimization / alignment | RLHF and alignment, Reinforcement Learning |
Self-supervision is the engine. It is what let pretraining escape the labeling bottleneck and consume the internet. Two families are worth naming specifically, because they show that self-supervision is broader than next-token prediction.
Siamese or joint-embedding networks use two weight-sharing encoder towers to map two views of the same datum to embeddings; the loss pulls matching pairs together and pushes non-matching pairs apart. This is the backbone of contrastive learning (SimCLR, MoCo, CLIP’s dual encoder) and of metric learning (face verification, retrieval). The classic failure mode is representation collapse, in which everything maps to one point, and the fixes define the field: negative pairs (SimCLR), a momentum target encoder (BYOL, MoCo), stop-gradient plus a predictor (SimSiam), and redundancy-reduction objectives (Barlow Twins, VICReg).
JEPA (Joint-Embedding Predictive Architecture) is LeCun’s non-generative self-supervision. Instead of reconstructing pixels or tokens, which is generative and wastes capacity on noise, it predicts the representation of a masked target from a context, in embedding space. I-JEPA (images) and V-JEPA and V-JEPA 2 (video, a step toward world models) avoid collapse with an asymmetric context and target encoder, an EMA target, and a predictor. The thesis is to model the world in an abstract latent space, not pixel by pixel. Contrast this with generative pretraining and with diffusion, both of which do reconstruct the input.
The lifecycle, stage by stage
Section titled “The lifecycle, stage by stage”The paradigms are applied in a fixed order, looping back on every iteration: data curation, pretraining, mid-training, SFT, preference optimization, evaluation, deployment, and monitoring.
- Data curation (unsupervised): crawl, deduplicate, filter, decontaminate against evals, and balance the mixture. Data is the source code now; most of the quality lives here.
- Pretraining (self-supervised): next-token loss over trillions of tokens. This stage dominates compute and is governed by scaling laws, such as Chinchilla-optimal data-to-parameter ratios.
- Mid-training or continued pretraining: long-context extension, up-weighting of domain or code data, and annealing on high-quality data.
- SFT (supervised): a smaller, curated set of instruction-response demonstrations teaches the format of being helpful.
- Preference optimization (RL from feedback): RLHF with a reward model and PPO; or DPO, which skips the reward model; or RLAIF and Constitutional AI, with AI-generated preferences; or GRPO for reasoning. This is where helpfulness, harmlessness, and style are dialed in.
- Evaluation: not pass/fail tests but distributional evals (MMLU, GPQA, SWE-bench, LMArena) and behavioral red-teaming, where a regression means a benchmark score dropping. The Statistical Learning chapter covers honest evaluation.
- Deployment: the artifact is the weights. Quantize them (Quantization: Math to Code), pick a runtime (Inference Frameworks), and serve with a KV cache (LLM Systems & Inference).
- Monitoring and iteration: watch for drift, jailbreaks, and regressions; collect production preferences; and feed them back into the next SFT or preference round.
The LLM lifecycle versus the software SDLC
Section titled “The LLM lifecycle versus the software SDLC”Set side by side, the two lifecycles share stage names but differ in almost every stage’s content:
| Stage | Traditional software SDLC | LLM development lifecycle |
|---|---|---|
| Requirements | specs, user stories | capability target + evals defined first |
| Design | architecture, modules, interfaces | data mixture, tokenizer, model architecture |
| Implementation | humans write deterministic code | pretraining grows weights from data (self-supervised) |
| Refinement | (none) | SFT (supervised) + preference optimization (RLHF/DPO) |
| Testing | unit/integration/e2e, deterministic pass/fail | evals: statistical, behavioral, red-team; “regression” = score drop |
| Build artifact | a versioned binary | a set of weights (+ tokenizer + config) |
| Deployment | CI/CD, blue-green | quantize → serve; same weights, many quantizations |
| Maintenance | patch the buggy line | can’t patch a line: mitigate with more data, more alignment, guardrails, or a retrain |
| Version control | git over source | git over source + data + weights + eval provenance |
Four differences matter most. First, behavior is specified versus emergent: code does exactly what is written, while a model does what the data made statistically likely, so you debug a distribution, not a line. Second, fixes are deterministic versus probabilistic: a software bug has a root-cause fix, while a model failure is reduced, by more SFT data, a preference pass, or a guardrail, and rarely eliminated. Third, “it compiles” has no analog: the closest signal is a loss curve plus eval scores, and success is graded, not binary. Fourth, the source of truth moved: in software the code is canonical, while for an LLM the data and the eval set are canonical and the weights are a build output. Reproducibility means versioning data and experiments, not just code, and the Pragmatic Programmer’s principles of DRY and reversibility from Software Engineering still apply, to your data and pipeline.
The engineering practices of the right-hand column, review, testing as evals, reproducible builds, and deprecation, are exactly Software Engineering applied to ML. The two lifecycles diverge in what you build but converge on how to build it responsibly. For a contrast with the classic software lifecycle, read Software Engineering at Google.
Where this leads
Section titled “Where this leads”This chapter sits between the foundations and the systems. The architecture foundations, transformers, attention, scaling laws, and VAE and diffusion basics, come from Deep Learning, which also covers the self-supervised, Siamese, contrastive, and JEPA objectives behind pretraining and the RLHF and DPO methods for post-training. Running these models, with KV caches, GQA and MLA, FlashAttention, and serving, is the subject of LLM Systems & Inference; making them fit with GGUF, AWQ, and FP8 is Quantization: Math to Code; and the candle, diffusers, and transformers runtimes where they execute are mapped in Inference Frameworks. The pipeline from pretraining through post-training is worked out in detail in Training and Post-Training. The KL divergence, score, and entropy in the diffusion and VAE objectives come from Information Theory in Mathematics, and building responsibly across the LLM lifecycle connects to Software Engineering.
This material appears throughout the industry: in Gemma and Gemini architecture, multimodality, and diffusion (Imagen, Veo) at Google DeepMind; in GPT architecture, multimodality, and scaling at OpenAI; in transformer internals, interpretability, and post-training at Anthropic; in the Llama recipe and open-weight strategy at Meta; in the Transformers and Diffusers open ecosystem at Hugging Face; and in Flux and Stable Diffusion, with flow matching and MMDiT, at Black Forest Labs and Stability.
Further reading
Section titled “Further reading”- Stanford CRFM, On the Opportunities and Risks of Foundation Models, the paper that named the field
- Hugging Face Transformers and Diffusers documentation
- Jay Alammar, The Illustrated Transformer
- Andrej Karpathy, Let’s build GPT
- Lilian Weng, What are Diffusion Models?
- On the lifecycle and training paradigms: Karpathy’s State of GPT (the canonical pretraining → SFT → reward modeling → RLHF walkthrough) and Deep Dive into LLMs like ChatGPT; the Hugging Face TRL docs (SFT, reward, PPO, DPO, and GRPO trainers) and Alignment Handbook; the Llama 3 Herd of Models tech report (an end-to-end real pipeline); and the InstructGPT, DPO, and Constitutional AI papers
- Software Engineering at Google, for the classic software SDLC
Key terms
Section titled “Key terms”- foundation model: a model pretrained on broad data at scale and then adapted to many downstream tasks.
- adaptation ladder: the sequence of increasingly expensive ways to specialize a model, from prompting through RAG and fine-tuning to continued pretraining.
- RoPE: rotary position embedding, which rotates queries and keys by position to encode relative position.
- SwiGLU: a gated MLP, , that replaced the ReLU feed-forward block.
- GQA / MLA: attention variants that shrink the KV cache by sharing K/V heads across groups of query heads, or by compressing K/V into a low-rank latent.
- patchify: cutting an image into a grid of patches, each embedded as one token.
- classifier-free guidance: combining conditional and unconditional denoising predictions with weight to trade diversity for prompt adherence.
- flow matching: training a velocity field along straight paths between noise and data, giving fewer, straighter sampling steps.
- JEPA: a non-generative self-supervised architecture that predicts the embedding of a masked target rather than reconstructing it.
- representation collapse: the failure of joint-embedding training in which all inputs map to the same point.
Summary
Section titled “Summary”- A foundation model is pretrained once and adapted many times; most practitioners now build with models, with latency and cost as first-class constraints.
- The transformer has converged to a recipe, decoder-only with pre-norm, RMSNorm, RoPE, SwiGLU, and GQA, optionally MoE, and the major open families differ mostly at the margins.
- Attention is the architectural battleground: MHA, MQA, GQA, and MLA trade quality for KV-cache size, while sliding-window and sparse variants trade global context for linear cost.
- Everything is tokens: text subwords, image patches, and audio codec codes or spectrogram frames all feed one architecture, which is how models went multimodal.
- Diffusion generates by denoising, and modern diffusion is a transformer (DiT) trained with flow matching, converging with the LLM stack.
- Building an LLM is not the software SDLC: behavior is grown from data through self-supervised pretraining, SFT, and preference optimization, so tests become evals and fixes become more data and alignment.
Review questions
Section titled “Review questions”- Why did foundation models shift most practitioners from training models to adapting them, and what is the cheapest-to-most-expensive order of adaptation methods?
Answer
Pretraining on internet-scale data yields general representations and emergent capabilities, such as in-context learning, that a per-task model cannot match, and pretraining is expensive enough that few teams repeat it. Adaptation, in order of cost, is prompting, few-shot prompting, RAG, PEFT such as LoRA, full fine-tuning, and continued pretraining. - List the components of the modern decoder-only recipe and say what each replaced and why.
Answer
Pre-norm replaced post-norm for stable deep training; RMSNorm replaced LayerNorm because it is cheaper; RoPE replaced learned or sinusoidal positions because it encodes relative position and extrapolates; SwiGLU replaced the ReLU FFN for better quality per parameter; GQA replaced MHA for a smaller KV cache; and MoE optionally replaces the dense MLP to add parameters without adding per-token FLOPs. - Why is attention called a fight over the KV cache, and how do MQA, GQA, and MLA differ?
Answer
During decoding every token reads all previous keys and values, so the number and size of K/V heads set the cache size and therefore how many concurrent users fit in memory. MQA shares a single K/V head across all query heads (tiny cache, some quality loss), GQA uses a few shared groups (the standard compromise), and MLA compresses K/V into a low-rank latent (DeepSeek's large cache savings). - Why does audio need a codec or spectrogram front end while text does not?
Answer
Text is discrete and low-rate, so subword tokens are already a manageable sequence. Audio is continuous and high-rate, at 16,000 or more samples per second, so it must be converted to spectrogram frames or quantized into discrete codec codes (for example EnCodec or SoundStream with RVQ) to reach a token rate a transformer can handle, and streaming latency matters more. - State the DDPM training loss and the flow-matching loss, and explain the practical advantage of flow matching.
Answer
DDPM trains $\epsilon_\theta(x_t, t)$ to predict the added noise, minimizing $\mathbb{E}\lVert \epsilon - \epsilon_\theta(x_t, t) \rVert^2$. Flow matching learns a velocity field along the straight path $x_t = (1 - t)x_0 + t x_1$, minimizing $\mathbb{E}\lVert v_\theta - (x_1 - x_0) \rVert^2$. Straighter paths need fewer sampling steps. - How does JEPA differ from contrastive Siamese learning and from generative pretraining?
Answer
Contrastive Siamese networks pull embeddings of two views of the same datum together and push other pairs apart, guarding against collapse with negatives, momentum encoders, or stop-gradients. Generative pretraining reconstructs tokens or pixels. JEPA predicts the embedding of a masked target from a context, entirely in representation space, avoiding collapse with asymmetric encoders, an EMA target, and a predictor, so it spends no capacity modeling unpredictable detail. - Give the four differences between the LLM lifecycle and the software SDLC that matter most.
Answer
Behavior is emergent rather than specified, so you debug a distribution; failures are reduced probabilistically rather than fixed at a root cause; there is no "it compiles", only graded loss curves and eval scores; and the source of truth is the data and eval set, with weights as a build output, so reproducibility requires versioning data, weights, and eval provenance as well as code.