Foundation models and modalities
What makes a foundation model
A foundation model is trained on broad data and can be adapted to many downstream tasks. Not every foundation model generates content: a pretrained encoder can support classification and retrieval. A generative model may be small and specialized rather than foundational. A model family describes related architectures or checkpoints; a hosted service may expose particular versions with separate limits, terms and interfaces. Do not assume the service name identifies exact weights.
Training, adaptation and inference
Pretraining learns parameters from a broad training objective; adaptation can update all or some parameters using task-specific data. Prompting or supplying examples at inference normally changes context without updating weights. Inference uses learned parameters to produce outputs, sometimes through repeated decoding steps. A model can be adapted poorly, and useful pretraining does not guarantee downstream quality. Check model cards for intended uses, limitations, training provenance where disclosed, license and evaluation conditions; independently verify the intended deployment.
Autoregressive generation
An autoregressive model factorizes sequence probability into conditional next-token probabilities: P(t1,...,tn) = product of P(ti | earlier tokens). At inference, greedy decoding picks the largest score at each step; sampling chooses according to a distribution. Greedy local choices need not maximize total sequence probability. Our tiny transition table conditions only on the last word, not the full prefix, and uses positive integer weights. It is an illustrative classical baseline, not a neural language model. Ties use lexical order; <END> is a reserved stopping token; start is an ordinary word, and the budget counts attempts to append new words. Missing transitions stop generation.
def generate(start, transitions, budget): if budget < 0: raise ValueError("budget must be nonnegative") output = [start] for _ in range(budget): choices = transitions.get(output[-1], {}) if not choices: break if any(w <= 0 for w in choices.values()): raise ValueError("weights must be positive") token = min(choices, key=lambda t: (-choices[t], t)) if token == "<END>": break output.append(token) return output
table = {"spring": {"seed": 3, "soil": 1}, "seed": {"guide": 2}, "guide": {"<END>": 1}}print(generate("spring", table, 5))print(generate("spring", table, 1))Expected outputs: ['spring', 'seed', 'guide'] and ['spring', 'seed']. In the first case the end marker is encountered and not appended. In the second the budget is exhausted. A self-loop is safe only because the budget is bounded. Sampling can produce different titles from the same table; probability and decoding details follow in Chapter 31.
To sample from positive integer weights, imagine consecutive slots: seed with weight 3 occupies slots 0, 1, 2; soil with weight 1 occupies slot 3. A uniformly chosen integer from 0 to total weight minus one selects a token with probability proportional to its weight. To implement the selection without randomness, accept the chosen integer as input, subtract each weight in order until the remaining integer is less than the current weight, and return that token. This permits deterministic tests at every interval boundary. Real neural generators usually use floating-point probabilities, not integer slots.
Diffusion and other generative families
Many diffusion models learn a reverse process for progressively removing noise, often using an explicit noise schedule and a neural predictor conditioned on text or other signals. Generation may begin with random noise and take repeated updates; some operate in a learned latent space. An autoencoder learns to reconstruct an input through an encoded representation; reconstruction alone does not establish a useful sampling distribution. A variational autoencoder adds a probabilistic latent model and a regularized training objective. A generative adversarial network trains a generator against a discriminator that learns to distinguish generated from training examples. These families differ in objectives, sampling, trade-offs and failure modes; they are not interchangeable.
A correction analogy, not a diffusion sampler
A small vector correction toward a supplied target illustrates gradual improvement. This is only arithmetic interpolation; a real diffusion model does not know the clean target during generation and predicts information needed by a reverse step. It has a schedule and possibly stochastic updates. Here the vectors are nonempty equal-length finite numeric lists, and strength is between zero and one.
def correction_step(noisy, estimate, strength): if len(noisy) != len(estimate) or not noisy: raise ValueError("equal nonempty vectors required") if not 0 <= strength <= 1: raise ValueError("strength must be between zero and one") return [x + strength * (target - x) for x, target in zip(noisy, estimate)]
print(correction_step([0, 8, 2], [4, 4, 4], 0.5))print(correction_step([2, 6, 3], [4, 4, 4], 0.5))Expected: [2.0, 6.0, 3.0], then [3.0, 5.0, 3.5]. Strength zero leaves the vector unchanged; strength one copies the estimate numerically. A wrong estimate moves values in the wrong direction. This is not a trained denoiser or evidence of image synthesis quality.
Modalities and evaluation
Text can be checked for claims, usefulness and constraints; code requires execution tests and security review; images require visual fidelity, prompt alignment and provenance; audio requires intelligibility and consent for voice use; video also requires temporal consistency. Multimodal systems combine input or output types, but a text-plus-image input system may only output text. Assess accessibility, privacy, licenses, uncertainty and failure modes in the intended environment. A high score on one modality does not establish another. No real images, voices, checkpoints or API calls are needed for this chapter.
Practice and handoff
Predict the greedy output after changing the transition weights or setting the budget to zero. Explain why the correction example is not diffusion. Draft a model-selection record with exact revision, supported input/output modalities, evaluation dataset, license, unknowns, and an abstention plan. Use Machine Learning for training depth and LLM Engineering for tokenization, alignment and serving. Proposed cross-track links remain unresolved until repository discovery.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Foundation models and modalities quiz
Apply the chapter concepts to synthetic content tasks.
Which property characterizes a foundation model in this lesson?
What does a zero generation budget produce in the toy function?
What limitation follows from choosing the highest-scoring next token greedily?
Why is correction_step only an analogy for diffusion?
Which evidence best supports selecting a model for a particular application?